nfs-ganesha 1.4
|
00001 /* 00002 * vim:expandtab:shiftwidth=8:tabstop=8: 00003 * 00004 * Copyright CEA/DAM/DIF (2008) 00005 * contributeur : Philippe DENIEL philippe.deniel@cea.fr 00006 * Thomas LEIBOVICI thomas.leibovici@cea.fr 00007 * 00008 * 00009 * This program is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 3 of the License, or (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00022 * 00023 * --------------------------------------- 00024 */ 00025 00033 #ifdef HAVE_CONFIG_H 00034 #include "config.h" 00035 #endif 00036 00037 #ifdef _SOLARIS 00038 #include "solaris_port.h" 00039 #endif 00040 00041 #include "ganesha_rpc.h" 00042 #include "nfs_init.h" 00043 #include "log.h" 00044 #include "fsal.h" 00045 #include "nfs23.h" 00046 #include "nfs4.h" 00047 #include "mount.h" 00048 #include "nlm4.h" 00049 #include "rquota.h" 00050 #include "nfs_core.h" 00051 #include "cache_inode.h" 00052 #include "cache_inode_lru.h" 00053 #include "err_cache_inode.h" 00054 #include "nfs_file_handle.h" 00055 #include "nfs_exports.h" 00056 #include "nfs_tools.h" 00057 #include "nfs_proto_functions.h" 00058 #include "nfs_dupreq.h" 00059 #include "config_parsing.h" 00060 #include "SemN.h" 00061 #include "external_tools.h" 00062 #include "nfs4_acls.h" 00063 #include "nfs_rpc_callback.h" 00064 #ifdef USE_DBUS 00065 #include "ganesha_dbus.h" 00066 #endif 00067 #ifdef _USE_CB_SIMULATOR 00068 #include "nfs_rpc_callback_simulator.h" 00069 #endif 00070 #include <sys/time.h> 00071 #include <sys/resource.h> 00072 #include <unistd.h> 00073 #include <string.h> 00074 #include <signal.h> 00075 #include <math.h> 00076 #ifdef _USE_NLM 00077 #include "nlm_util.h" 00078 #include "nsm.h" 00079 #endif 00080 #include "sal_functions.h" 00081 #include "nfs_tcb.h" 00082 #include "nfs_tcb.h" 00083 00084 /* global information exported to all layers (as extern vars) */ 00085 00086 /* nfs_parameter_t nfs_param = {0}; */ 00087 nfs_parameter_t nfs_param; 00088 00089 /* ServerEpoch is ServerBootTime unless overriden by -E command line option */ 00090 time_t ServerBootTime; 00091 time_t ServerEpoch; 00092 00093 nfs_worker_data_t *workers_data = NULL; 00094 hash_table_t *fh_to_cache_entry_ht = NULL; /* Cache inode handle lookup table */ 00095 verifier4 NFS4_write_verifier; /* NFS V4 write verifier */ 00096 writeverf3 NFS3_write_verifier; /* NFS V3 write verifier */ 00097 00098 /* node ID used to identify an individual node in a cluster */ 00099 ushort g_nodeid = 0; 00100 00101 hash_table_t *ht_ip_stats[NB_MAX_WORKER_THREAD]; 00102 nfs_start_info_t nfs_start_info; 00103 00104 pthread_t worker_thrid[NB_MAX_WORKER_THREAD]; 00105 00106 pthread_t flusher_thrid[NB_MAX_FLUSHER_THREAD]; 00107 nfs_flush_thread_data_t flush_info[NB_MAX_FLUSHER_THREAD]; 00108 00109 pthread_t stat_thrid; 00110 pthread_t stat_exporter_thrid; 00111 pthread_t admin_thrid; 00112 pthread_t fcc_gc_thrid; 00113 pthread_t sigmgr_thrid; 00114 pthread_t reaper_thrid; 00115 pthread_t gsh_dbus_thrid; 00116 pthread_t upp_thrid; 00117 nfs_tcb_t gccb; 00118 00119 #ifdef _USE_9P 00120 pthread_t _9p_dispatcher_thrid; 00121 #endif 00122 00123 #ifdef _USE_UPCALL_SIMULATOR 00124 pthread_t upcall_simulator_thrid; 00125 #endif 00126 00127 char config_path[MAXPATHLEN]; 00128 00129 char pidfile_path[MAXPATHLEN] ; 00130 00139 void *sigmgr_thread( void * UnusedArg ) 00140 { 00141 SetNameFunction("sigmgr"); 00142 int signal_caught = 0; 00143 fsal_status_t st; 00144 00145 /* Loop until we catch SIGTERM */ 00146 while(signal_caught != SIGTERM) 00147 { 00148 sigset_t signals_to_catch; 00149 sigemptyset(&signals_to_catch); 00150 sigaddset(&signals_to_catch, SIGTERM); 00151 sigaddset(&signals_to_catch, SIGHUP); 00152 if(sigwait(&signals_to_catch, &signal_caught) != 0) 00153 { 00154 LogFullDebug(COMPONENT_THREAD, 00155 "sigwait exited with error"); 00156 continue; 00157 } 00158 if(signal_caught == SIGHUP) 00159 { 00160 LogEvent(COMPONENT_MAIN, 00161 "SIGHUP_HANDLER: Received SIGHUP.... initiating export list reload"); 00162 admin_replace_exports(); 00163 } 00164 } 00165 00166 LogEvent(COMPONENT_MAIN, "NFS EXIT: stopping NFS service"); 00167 LogDebug(COMPONENT_THREAD, "Stopping worker threads"); 00168 00169 if(pause_threads(PAUSE_SHUTDOWN) != PAUSE_EXIT) 00170 LogDebug(COMPONENT_THREAD, 00171 "Unexpected return code from pause_threads"); 00172 else 00173 LogDebug(COMPONENT_THREAD, 00174 "Done waiting for worker threads to exit"); 00175 00176 LogEvent(COMPONENT_MAIN, "NFS EXIT: synchonizing FSAL"); 00177 00178 st = FSAL_terminate(); 00179 00180 if(FSAL_IS_ERROR(st)) 00181 LogCrit(COMPONENT_MAIN, "NFS EXIT: ERROR %d.%d while synchonizing FSAL", 00182 st.major, st.minor); 00183 00184 LogDebug(COMPONENT_THREAD, "sigmgr thread exiting"); 00185 00186 /* Remove pid file. I do not check for status (best effort, 00187 * the daemon is stopping anyway */ 00188 unlink( pidfile_path ) ; 00189 00190 /* Might as well exit - no need for this thread any more */ 00191 return NULL; 00192 } /* sigmgr_thread */ 00193 00198 void nfs_prereq_init(char *program_name, char *host_name, int debug_level, char *log_path) 00199 { 00200 /* Initialize logging */ 00201 SetNamePgm(program_name); 00202 SetNameFunction("main"); 00203 SetNameHost(host_name); 00204 InitLogging(); 00205 if (log_path[0] != '\0') 00206 SetDefaultLogging(log_path); 00207 00208 if (debug_level >= 0) 00209 SetLogLevel(debug_level); 00210 00211 /* Register error families */ 00212 AddFamilyError(ERR_POSIX, "POSIX Errors", tab_systeme_status); 00213 AddFamilyError(ERR_LRU, "LRU related Errors", tab_errctx_LRU); 00214 AddFamilyError(ERR_HASHTABLE, "HashTable related Errors", tab_errctx_hash); 00215 AddFamilyError(ERR_FSAL, "FSAL related Errors", tab_errstatus_FSAL); 00216 AddFamilyError(ERR_CACHE_INODE, "Cache Inode related Errors", 00217 tab_errstatus_cache_inode); 00218 } 00219 00224 void nfs_print_param_config() 00225 { 00226 printf("NFS_Core_Param\n{\n"); 00227 00228 printf("\tNFS_Port = %u ;\n", nfs_param.core_param.port[P_NFS]); 00229 printf("\tMNT_Port = %u ;\n", nfs_param.core_param.port[P_MNT]); 00230 printf("\tNFS_Program = %u ;\n", nfs_param.core_param.program[P_NFS]); 00231 printf("\tMNT_Program = %u ;\n", nfs_param.core_param.program[P_NFS]); 00232 printf("\tNb_Worker = %u ; \n", nfs_param.core_param.nb_worker); 00233 printf("\tb_Call_Before_Queue_Avg = %u ; \n", nfs_param.core_param.nb_call_before_queue_avg); 00234 printf("\tNb_MaxConcurrentGC = %u ; \n", nfs_param.core_param.nb_max_concurrent_gc); 00235 printf("\tDupReq_Expiration = %lu ; \n", nfs_param.core_param.expiration_dupreq); 00236 printf("\tCore_Dump_Size = %ld ; \n", nfs_param.core_param.core_dump_size); 00237 printf("\tNb_Max_Fd = %d ; \n", nfs_param.core_param.nb_max_fd); 00238 printf("\tStats_File_Path = %s ; \n", nfs_param.core_param.stats_file_path); 00239 printf("\tStats_Update_Delay = %d ; \n", nfs_param.core_param.stats_update_delay); 00240 printf("\tLong_Processing_Threshold = %d ; \n", nfs_param.core_param.long_processing_threshold); 00241 printf("\tTCP_Fridge_Expiration_Delay = %d ; \n", nfs_param.core_param.tcp_fridge_expiration_delay); 00242 printf("\tStats_Per_Client_Directory = %s ; \n", 00243 nfs_param.core_param.stats_per_client_directory); 00244 00245 if(nfs_param.core_param.dump_stats_per_client) 00246 printf("\tDump_Stats_Per_Client = TRUE ; \n"); 00247 else 00248 printf("\tDump_Stats_Per_Client = FALSE ;\n"); 00249 00250 if(nfs_param.core_param.drop_io_errors) 00251 printf("\tDrop_IO_Errors = TRUE ; \n"); 00252 else 00253 printf("\tDrop_IO_Errors = FALSE ;\n"); 00254 00255 if(nfs_param.core_param.drop_inval_errors) 00256 printf("\tDrop_Inval_Errors = TRUE ; \n"); 00257 else 00258 printf("\tDrop_Inval_Errors = FALSE ;\n"); 00259 00260 if(nfs_param.core_param.drop_delay_errors) 00261 printf("\tDrop_Delay_Errors = TRUE ; \n"); 00262 else 00263 printf("\tDrop_Delay_Errors = FALSE ;\n"); 00264 00265 printf("}\n\n"); 00266 00267 printf("NFS_Worker_Param\n{\n"); 00268 printf("}\n\n"); 00269 } /* nfs_print_param_config */ 00270 00275 void nfs_set_param_default() 00276 { 00277 /* Core parameters */ 00278 nfs_param.core_param.nb_worker = NB_WORKER_THREAD_DEFAULT; 00279 nfs_param.core_param.nb_call_before_queue_avg = NB_REQUEST_BEFORE_QUEUE_AVG; 00280 nfs_param.core_param.nb_max_concurrent_gc = NB_MAX_CONCURRENT_GC; 00281 nfs_param.core_param.expiration_dupreq = DUPREQ_EXPIRATION; 00282 nfs_param.core_param.port[P_NFS] = NFS_PORT; 00283 nfs_param.core_param.port[P_MNT] = 0; 00284 nfs_param.core_param.bind_addr.sin_family = AF_INET; /* IPv4 only right now */ 00285 nfs_param.core_param.bind_addr.sin_addr.s_addr = INADDR_ANY; /* All the interfaces on the machine are used */ 00286 nfs_param.core_param.bind_addr.sin_port = 0; /* No port specified */ 00287 nfs_param.core_param.program[P_NFS] = NFS_PROGRAM; 00288 nfs_param.core_param.program[P_MNT] = MOUNTPROG; 00289 #ifdef _USE_NLM 00290 nfs_param.core_param.program[P_NLM] = NLMPROG; 00291 nfs_param.core_param.port[P_NLM] = 0; 00292 #endif 00293 #ifdef _USE_9P 00294 nfs_param._9p_param._9p_port = _9P_PORT ; 00295 #endif 00296 #ifdef _USE_RQUOTA 00297 nfs_param.core_param.program[P_RQUOTA] = RQUOTAPROG; 00298 nfs_param.core_param.port[P_RQUOTA] = RQUOTA_PORT; 00299 #endif 00300 nfs_param.core_param.drop_io_errors = TRUE; 00301 nfs_param.core_param.drop_inval_errors = FALSE; 00302 nfs_param.core_param.drop_delay_errors = TRUE; 00303 nfs_param.core_param.core_dump_size = -1; 00304 nfs_param.core_param.nb_max_fd = 1024; 00305 nfs_param.core_param.stats_update_delay = 60; 00306 nfs_param.core_param.long_processing_threshold = 10; /* seconds */ 00307 nfs_param.core_param.tcp_fridge_expiration_delay = -1; 00308 /* only NFSv4 is supported for the FSAL_PROXY */ 00309 #if ! defined( _USE_PROXY ) || defined ( _HANDLE_MAPPING ) 00310 nfs_param.core_param.core_options = CORE_OPTION_NFSV3 | CORE_OPTION_NFSV4; 00311 #else 00312 nfs_param.core_param.core_options = CORE_OPTION_NFSV4; 00313 #endif /* _USE_PROXY */ 00314 00315 nfs_param.core_param.use_nfs_commit = FALSE; 00316 strncpy(nfs_param.core_param.stats_file_path, "/tmp/ganesha.stat", MAXPATHLEN); 00317 nfs_param.core_param.dump_stats_per_client = 0; 00318 strncpy(nfs_param.core_param.stats_per_client_directory, "/tmp", MAXPATHLEN); 00319 00320 nfs_param.core_param.max_send_buffer_size = NFS_DEFAULT_SEND_BUFFER_SIZE; 00321 nfs_param.core_param.max_recv_buffer_size = NFS_DEFAULT_RECV_BUFFER_SIZE; 00322 00323 #ifdef _USE_NLM 00324 nfs_param.core_param.nsm_use_caller_name = FALSE; 00325 #endif 00326 00327 nfs_param.core_param.clustered = FALSE; 00328 00329 /* Worker parameters : LRU dupreq */ 00330 nfs_param.worker_param.lru_dupreq.nb_call_gc_invalid = 100; 00331 nfs_param.worker_param.lru_dupreq.clean_entry = clean_entry_dupreq; 00332 nfs_param.worker_param.lru_dupreq.entry_to_str = print_entry_dupreq; 00333 nfs_param.worker_param.lru_dupreq.lp_name = "Worker DupReq LRU"; 00334 00335 /* Worker parameters : GC */ 00336 nfs_param.worker_param.nb_before_gc = NB_REQUEST_BEFORE_GC; 00337 00338 #ifdef _HAVE_GSSAPI 00339 /* krb5 parameter */ 00340 strlcpy(nfs_param.krb5_param.svc.principal, DEFAULT_NFS_PRINCIPAL, 00341 sizeof(nfs_param.krb5_param.svc.principal)); 00342 strlcpy(nfs_param.krb5_param.keytab, DEFAULT_NFS_KEYTAB, 00343 sizeof(nfs_param.krb5_param.keytab)); 00344 strlcpy(nfs_param.krb5_param.ccache_dir, DEFAULT_NFS_CCACHE_DIR, 00345 sizeof(nfs_param.krb5_param.ccache_dir)); 00346 nfs_param.krb5_param.active_krb5 = TRUE; 00347 nfs_param.krb5_param.hash_param.index_size = PRIME_ID_MAPPER; 00348 nfs_param.krb5_param.hash_param.alphabet_length = 10; /* Not used for UID_MAPPER */ 00349 nfs_param.krb5_param.hash_param.hash_func_key = gss_ctx_hash_func; 00350 nfs_param.krb5_param.hash_param.hash_func_rbt = gss_ctx_rbt_hash_func; 00351 nfs_param.krb5_param.hash_param.hash_func_both = NULL ; /* BUGAZOMEU */ 00352 nfs_param.krb5_param.hash_param.compare_key = compare_gss_ctx; 00353 nfs_param.krb5_param.hash_param.key_to_str = display_gss_ctx; 00354 nfs_param.krb5_param.hash_param.val_to_str = display_gss_svc_data; 00355 nfs_param.krb5_param.hash_param.ht_name = "KRB5 ID Mapper"; 00356 nfs_param.krb5_param.hash_param.flags = HT_FLAG_NONE; 00357 nfs_param.krb5_param.hash_param.ht_log_component = COMPONENT_IDMAPPER; 00358 #endif 00359 00360 /* NFSv4 parameter */ 00361 nfs_param.nfsv4_param.lease_lifetime = NFS4_LEASE_LIFETIME; 00362 nfs_param.nfsv4_param.fh_expire = FALSE; 00363 nfs_param.nfsv4_param.returns_err_fh_expired = TRUE; 00364 nfs_param.nfsv4_param.return_bad_stateid = TRUE; 00365 strncpy(nfs_param.nfsv4_param.domainname, DEFAULT_DOMAIN, MAXNAMLEN); 00366 strncpy(nfs_param.nfsv4_param.idmapconf, DEFAULT_IDMAPCONF, MAXPATHLEN); 00367 00368 /* Worker parameters : dupreq hash table */ 00369 nfs_param.dupreq_param.hash_param.index_size = PRIME_DUPREQ; 00370 nfs_param.dupreq_param.hash_param.alphabet_length = 10; /* Xid is a numerical decimal value */ 00371 nfs_param.dupreq_param.hash_param.hash_func_key = dupreq_value_hash_func; 00372 nfs_param.dupreq_param.hash_param.hash_func_rbt = dupreq_rbt_hash_func; 00373 nfs_param.dupreq_param.hash_param.compare_key = compare_req; 00374 nfs_param.dupreq_param.hash_param.key_to_str = display_req_key; 00375 nfs_param.dupreq_param.hash_param.val_to_str = display_req_val; 00376 nfs_param.dupreq_param.hash_param.ht_name = "Duplicate Request Cache"; 00377 nfs_param.dupreq_param.hash_param.flags = HT_FLAG_NONE; /* ! */ 00378 nfs_param.dupreq_param.hash_param.ht_log_component = COMPONENT_DUPREQ; 00379 00380 /* Worker parameters : IP/name hash table */ 00381 nfs_param.ip_name_param.hash_param.index_size = PRIME_IP_NAME; 00382 nfs_param.ip_name_param.hash_param.alphabet_length = 10; /* ipaddr is a numerical decimal value */ 00383 nfs_param.ip_name_param.hash_param.hash_func_key = ip_name_value_hash_func; 00384 nfs_param.ip_name_param.hash_param.hash_func_rbt = ip_name_rbt_hash_func; 00385 nfs_param.ip_name_param.hash_param.compare_key = compare_ip_name; 00386 nfs_param.ip_name_param.hash_param.key_to_str = display_ip_name_key; 00387 nfs_param.ip_name_param.hash_param.val_to_str = display_ip_name_val; 00388 nfs_param.ip_name_param.hash_param.ht_name = "IP Name"; 00389 nfs_param.ip_name_param.hash_param.flags = HT_FLAG_NONE; 00390 nfs_param.ip_name_param.hash_param.ht_log_component = COMPONENT_DISPATCH; 00391 nfs_param.ip_name_param.expiration_time = IP_NAME_EXPIRATION; 00392 strncpy(nfs_param.ip_name_param.mapfile, "", MAXPATHLEN); 00393 00394 /* Worker parameters : UID_MAPPER hash table */ 00395 nfs_param.uidmap_cache_param.hash_param.index_size = PRIME_ID_MAPPER; 00396 nfs_param.uidmap_cache_param.hash_param.alphabet_length = 10; /* Not used for UID_MAPPER */ 00397 nfs_param.uidmap_cache_param.hash_param.hash_func_key = idmapper_value_hash_func; 00398 nfs_param.uidmap_cache_param.hash_param.hash_func_rbt = idmapper_rbt_hash_func; 00399 nfs_param.uidmap_cache_param.hash_param.compare_key = compare_idmapper; 00400 nfs_param.uidmap_cache_param.hash_param.key_to_str = display_idmapper_key; 00401 nfs_param.uidmap_cache_param.hash_param.val_to_str = display_idmapper_val; 00402 nfs_param.uidmap_cache_param.hash_param.ht_name = "UID Map Cache"; 00403 nfs_param.uidmap_cache_param.hash_param.flags = HT_FLAG_NONE; 00404 nfs_param.uidmap_cache_param.hash_param.ht_log_component = COMPONENT_IDMAPPER; 00405 strncpy(nfs_param.uidmap_cache_param.mapfile, "", MAXPATHLEN); 00406 00407 /* Worker parameters : UNAME_MAPPER hash table */ 00408 nfs_param.unamemap_cache_param.hash_param.index_size = PRIME_ID_MAPPER; 00409 nfs_param.unamemap_cache_param.hash_param.alphabet_length = 10; /* Not used for UID_MAPPER */ 00410 nfs_param.unamemap_cache_param.hash_param.hash_func_key = namemapper_value_hash_func; 00411 nfs_param.unamemap_cache_param.hash_param.hash_func_rbt = namemapper_rbt_hash_func; 00412 nfs_param.unamemap_cache_param.hash_param.compare_key = compare_namemapper; 00413 nfs_param.unamemap_cache_param.hash_param.key_to_str = display_idmapper_val; 00414 nfs_param.unamemap_cache_param.hash_param.val_to_str = display_idmapper_key; 00415 nfs_param.unamemap_cache_param.hash_param.ht_name = "UNAME Map Cache"; 00416 nfs_param.unamemap_cache_param.hash_param.flags = HT_FLAG_NONE; 00417 nfs_param.unamemap_cache_param.hash_param.ht_log_component = COMPONENT_IDMAPPER; 00418 strncpy(nfs_param.unamemap_cache_param.mapfile, "", MAXPATHLEN); 00419 00420 /* Worker parameters : GID_MAPPER hash table */ 00421 nfs_param.gidmap_cache_param.hash_param.index_size = PRIME_ID_MAPPER; 00422 nfs_param.gidmap_cache_param.hash_param.alphabet_length = 10; /* Not used for UID_MAPPER */ 00423 nfs_param.gidmap_cache_param.hash_param.hash_func_key = idmapper_value_hash_func; 00424 nfs_param.gidmap_cache_param.hash_param.hash_func_rbt = idmapper_rbt_hash_func; 00425 nfs_param.gidmap_cache_param.hash_param.compare_key = compare_idmapper; 00426 nfs_param.gidmap_cache_param.hash_param.key_to_str = display_idmapper_key; 00427 nfs_param.gidmap_cache_param.hash_param.val_to_str = display_idmapper_val; 00428 nfs_param.gidmap_cache_param.hash_param.ht_name = "GID Map Cache"; 00429 nfs_param.gidmap_cache_param.hash_param.flags = HT_FLAG_NONE; 00430 nfs_param.gidmap_cache_param.hash_param.ht_log_component = COMPONENT_IDMAPPER; 00431 strncpy(nfs_param.gidmap_cache_param.mapfile, "", MAXPATHLEN); 00432 00433 /* Worker parameters : UID->GID hash table (for RPCSEC_GSS) */ 00434 nfs_param.uidgidmap_cache_param.hash_param.index_size = PRIME_ID_MAPPER; 00435 nfs_param.uidgidmap_cache_param.hash_param.alphabet_length = 10; /* Not used for UID_MAPPER */ 00436 nfs_param.uidgidmap_cache_param.hash_param.hash_func_key = 00437 namemapper_value_hash_func; 00438 nfs_param.uidgidmap_cache_param.hash_param.hash_func_rbt = namemapper_rbt_hash_func; 00439 nfs_param.uidgidmap_cache_param.hash_param.compare_key = compare_namemapper; 00440 nfs_param.uidgidmap_cache_param.hash_param.key_to_str = display_idmapper_key; 00441 nfs_param.uidgidmap_cache_param.hash_param.val_to_str = display_idmapper_key; 00442 nfs_param.uidgidmap_cache_param.hash_param.ht_name = "UID->GID Map Cache"; 00443 nfs_param.uidgidmap_cache_param.hash_param.flags = HT_FLAG_NONE; 00444 nfs_param.uidgidmap_cache_param.hash_param.ht_log_component = COMPONENT_IDMAPPER; 00445 00446 /* Worker parameters : GNAME_MAPPER hash table */ 00447 nfs_param.gnamemap_cache_param.hash_param.index_size = PRIME_ID_MAPPER; 00448 nfs_param.gnamemap_cache_param.hash_param.alphabet_length = 10; /* Not used for UID_MAPPER */ 00449 nfs_param.gnamemap_cache_param.hash_param.hash_func_key = namemapper_value_hash_func; 00450 nfs_param.gnamemap_cache_param.hash_param.hash_func_rbt = namemapper_rbt_hash_func; 00451 nfs_param.gnamemap_cache_param.hash_param.compare_key = compare_namemapper; 00452 nfs_param.gnamemap_cache_param.hash_param.key_to_str = display_idmapper_val; 00453 nfs_param.gnamemap_cache_param.hash_param.val_to_str = display_idmapper_key; 00454 nfs_param.gnamemap_cache_param.hash_param.ht_name = "GNAME Map Cache"; 00455 nfs_param.gnamemap_cache_param.hash_param.flags = HT_FLAG_NONE; 00456 nfs_param.gnamemap_cache_param.hash_param.ht_log_component = COMPONENT_IDMAPPER; 00457 strncpy(nfs_param.gnamemap_cache_param.mapfile, "", MAXPATHLEN); 00458 00459 /* Worker parameters : IP/stats hash table */ 00460 nfs_param.ip_stats_param.hash_param.index_size = PRIME_IP_STATS; 00461 nfs_param.ip_stats_param.hash_param.alphabet_length = 10; /* ipaddr is a numerical decimal value */ 00462 nfs_param.ip_stats_param.hash_param.hash_func_key = ip_stats_value_hash_func; 00463 nfs_param.ip_stats_param.hash_param.hash_func_rbt = ip_stats_rbt_hash_func; 00464 nfs_param.ip_stats_param.hash_param.compare_key = compare_ip_stats; 00465 nfs_param.ip_stats_param.hash_param.key_to_str = display_ip_stats_key; 00466 nfs_param.ip_stats_param.hash_param.val_to_str = display_ip_stats_val; 00467 nfs_param.ip_stats_param.hash_param.ht_name = "IP Stats"; 00468 nfs_param.ip_stats_param.hash_param.flags = HT_FLAG_NONE; 00469 nfs_param.ip_stats_param.hash_param.ht_log_component = COMPONENT_DISPATCH; 00470 00471 /* Worker parameters : NFSv4 Unconfirmed Client id table */ 00472 nfs_param.client_id_param.cid_unconfirmed_hash_param.index_size = PRIME_CLIENT_ID; 00473 nfs_param.client_id_param.cid_unconfirmed_hash_param.alphabet_length = 10; /* ipaddr is a numerical decimal value */ 00474 nfs_param.client_id_param.cid_unconfirmed_hash_param.hash_func_key = client_id_value_hash_func; 00475 nfs_param.client_id_param.cid_unconfirmed_hash_param.hash_func_rbt = client_id_rbt_hash_func; 00476 nfs_param.client_id_param.cid_unconfirmed_hash_param.hash_func_both = NULL ; 00477 nfs_param.client_id_param.cid_unconfirmed_hash_param.compare_key = compare_client_id; 00478 nfs_param.client_id_param.cid_unconfirmed_hash_param.key_to_str = display_client_id_key; 00479 nfs_param.client_id_param.cid_unconfirmed_hash_param.val_to_str = display_client_id_val; 00480 nfs_param.client_id_param.cid_unconfirmed_hash_param.ht_name = "Unconfirmed Client ID"; 00481 nfs_param.client_id_param.cid_unconfirmed_hash_param.flags = HT_FLAG_CACHE; 00482 nfs_param.client_id_param.cid_unconfirmed_hash_param.ht_log_component = COMPONENT_CLIENTID; 00483 00484 /* Worker parameters : NFSv4 Confirmed Client id table */ 00485 nfs_param.client_id_param.cid_confirmed_hash_param.index_size = PRIME_CLIENT_ID; 00486 nfs_param.client_id_param.cid_confirmed_hash_param.alphabet_length = 10; /* ipaddr is a numerical decimal value */ 00487 nfs_param.client_id_param.cid_confirmed_hash_param.hash_func_key = client_id_value_hash_func; 00488 nfs_param.client_id_param.cid_confirmed_hash_param.hash_func_rbt = client_id_rbt_hash_func; 00489 nfs_param.client_id_param.cid_confirmed_hash_param.hash_func_both = NULL ; 00490 nfs_param.client_id_param.cid_confirmed_hash_param.compare_key = compare_client_id; 00491 nfs_param.client_id_param.cid_confirmed_hash_param.key_to_str = display_client_id_key; 00492 nfs_param.client_id_param.cid_confirmed_hash_param.val_to_str = display_client_id_val; 00493 nfs_param.client_id_param.cid_confirmed_hash_param.ht_name = "Confirmed Client ID"; 00494 nfs_param.client_id_param.cid_confirmed_hash_param.flags = HT_FLAG_CACHE; 00495 nfs_param.client_id_param.cid_confirmed_hash_param.ht_log_component = COMPONENT_CLIENTID; 00496 00497 /* Worker parameters : NFSv4 Client Record table */ 00498 nfs_param.client_id_param.cr_hash_param.index_size = PRIME_CLIENT_ID; 00499 nfs_param.client_id_param.cr_hash_param.alphabet_length = 10; /* ipaddr is a numerical decimal value */ 00500 nfs_param.client_id_param.cr_hash_param.hash_func_key = client_record_value_hash_func; 00501 nfs_param.client_id_param.cr_hash_param.hash_func_rbt = client_record_rbt_hash_func; 00502 nfs_param.client_id_param.cr_hash_param.hash_func_both = NULL ; 00503 nfs_param.client_id_param.cr_hash_param.compare_key = compare_client_record; 00504 nfs_param.client_id_param.cr_hash_param.key_to_str = display_client_record_key; 00505 nfs_param.client_id_param.cr_hash_param.val_to_str = display_client_record_val; 00506 nfs_param.client_id_param.cr_hash_param.ht_name = "Client Record"; 00507 nfs_param.client_id_param.cr_hash_param.flags = HT_FLAG_CACHE; 00508 nfs_param.client_id_param.cr_hash_param.ht_log_component = COMPONENT_CLIENTID; 00509 00510 /* NFSv4 State Id hash */ 00511 nfs_param.state_id_param.hash_param.index_size = PRIME_STATE_ID; 00512 /* ipaddr is a numerical decimal value */ 00513 nfs_param.state_id_param.hash_param.alphabet_length = 10; 00514 nfs_param.state_id_param.hash_param.hash_func_key = state_id_value_hash_func; 00515 nfs_param.state_id_param.hash_param.hash_func_rbt = state_id_rbt_hash_func; 00516 nfs_param.state_id_param.hash_param.hash_func_both = NULL; 00517 nfs_param.state_id_param.hash_param.compare_key = compare_state_id; 00518 nfs_param.state_id_param.hash_param.key_to_str = display_state_id_key; 00519 nfs_param.state_id_param.hash_param.val_to_str = display_state_id_val; 00520 nfs_param.state_id_param.hash_param.ht_name = "State ID"; 00521 nfs_param.state_id_param.hash_param.flags = HT_FLAG_CACHE; 00522 nfs_param.state_id_param.hash_param.ht_log_component = COMPONENT_STATE; 00523 00524 #ifdef _USE_NFS4_1 00525 /* NFSv4 Session Id hash */ 00526 nfs_param.session_id_param.hash_param.index_size = PRIME_STATE_ID; 00527 /* ipaddr is a numerical decimal value */ 00528 nfs_param.session_id_param.hash_param.alphabet_length = 10; 00529 nfs_param.session_id_param.hash_param.hash_func_key 00530 = session_id_value_hash_func; 00531 nfs_param.session_id_param.hash_param.hash_func_rbt 00532 = session_id_rbt_hash_func; 00533 nfs_param.session_id_param.hash_param.compare_key = compare_session_id; 00534 nfs_param.session_id_param.hash_param.key_to_str = display_session_id_key; 00535 nfs_param.session_id_param.hash_param.val_to_str = display_session_id_val; 00536 nfs_param.session_id_param.hash_param.ht_name = "Session ID"; 00537 nfs_param.session_id_param.hash_param.flags = HT_FLAG_CACHE; 00538 nfs_param.session_id_param.hash_param.ht_log_component = COMPONENT_SESSIONS; 00539 00540 #endif /* _USE_NFS4_1 */ 00541 00542 /* NFSv4 Open Owner hash */ 00543 nfs_param.nfs4_owner_param.hash_param.index_size = PRIME_STATE_ID; 00544 nfs_param.nfs4_owner_param.hash_param.alphabet_length = 10; /* ipaddr is a numerical decimal value */ 00545 nfs_param.nfs4_owner_param.hash_param.hash_func_key = nfs4_owner_value_hash_func; 00546 nfs_param.nfs4_owner_param.hash_param.hash_func_rbt = nfs4_owner_rbt_hash_func; 00547 nfs_param.nfs4_owner_param.hash_param.compare_key = compare_nfs4_owner_key; 00548 nfs_param.nfs4_owner_param.hash_param.key_to_str = display_nfs4_owner_key; 00549 nfs_param.nfs4_owner_param.hash_param.val_to_str = display_nfs4_owner_val; 00550 nfs_param.nfs4_owner_param.hash_param.ht_name = "NFS4 Owner"; 00551 nfs_param.nfs4_owner_param.hash_param.flags = HT_FLAG_CACHE; 00552 nfs_param.nfs4_owner_param.hash_param.ht_log_component = COMPONENT_STATE; 00553 00554 #ifdef _USE_NLM 00555 /* NSM Client hash */ 00556 nfs_param.nsm_client_hash_param.index_size = PRIME_STATE_ID; 00557 nfs_param.nsm_client_hash_param.alphabet_length = 10; /* ipaddr is a numerical decimal value */ 00558 nfs_param.nsm_client_hash_param.hash_func_key = nsm_client_value_hash_func; 00559 nfs_param.nsm_client_hash_param.hash_func_rbt = nsm_client_rbt_hash_func; 00560 nfs_param.nsm_client_hash_param.compare_key = compare_nsm_client_key; 00561 nfs_param.nsm_client_hash_param.key_to_str = display_nsm_client_key; 00562 nfs_param.nsm_client_hash_param.val_to_str = display_nsm_client_val; 00563 nfs_param.nsm_client_hash_param.ht_name = "NSM Client"; 00564 nfs_param.nsm_client_hash_param.flags = HT_FLAG_NONE; 00565 nfs_param.nsm_client_hash_param.ht_log_component = COMPONENT_STATE; 00566 00567 /* NLM Client hash */ 00568 nfs_param.nlm_client_hash_param.index_size = PRIME_STATE_ID; 00569 nfs_param.nlm_client_hash_param.alphabet_length = 10; /* ipaddr is a numerical decimal value */ 00570 nfs_param.nlm_client_hash_param.hash_func_key = nlm_client_value_hash_func; 00571 nfs_param.nlm_client_hash_param.hash_func_rbt = nlm_client_rbt_hash_func; 00572 nfs_param.nlm_client_hash_param.compare_key = compare_nlm_client_key; 00573 nfs_param.nlm_client_hash_param.key_to_str = display_nlm_client_key; 00574 nfs_param.nlm_client_hash_param.val_to_str = display_nlm_client_val; 00575 nfs_param.nlm_client_hash_param.ht_name = "NLM Client"; 00576 nfs_param.nlm_client_hash_param.flags = HT_FLAG_NONE; 00577 nfs_param.nlm_client_hash_param.ht_log_component = COMPONENT_STATE; 00578 00579 /* NLM Owner hash */ 00580 nfs_param.nlm_owner_hash_param.index_size = PRIME_STATE_ID; 00581 nfs_param.nlm_owner_hash_param.alphabet_length = 10; /* ipaddr is a numerical decimal value */ 00582 nfs_param.nlm_owner_hash_param.hash_func_key = nlm_owner_value_hash_func; 00583 nfs_param.nlm_owner_hash_param.hash_func_rbt = nlm_owner_rbt_hash_func; 00584 nfs_param.nlm_owner_hash_param.compare_key = compare_nlm_owner_key; 00585 nfs_param.nlm_owner_hash_param.key_to_str = display_nlm_owner_key; 00586 nfs_param.nlm_owner_hash_param.val_to_str = display_nlm_owner_val; 00587 nfs_param.nlm_owner_hash_param.ht_name = "NLM Owner"; 00588 nfs_param.nlm_owner_hash_param.flags = HT_FLAG_NONE; 00589 nfs_param.nlm_owner_hash_param.ht_log_component = COMPONENT_STATE; 00590 #endif 00591 #ifdef _USE_9P 00592 /* 9P Lock Owner hash */ 00593 nfs_param._9p_owner_hash_param.index_size = PRIME_STATE_ID; 00594 nfs_param._9p_owner_hash_param.alphabet_length = 10; /* ipaddr is a numerical decimal value */ 00595 nfs_param._9p_owner_hash_param.hash_func_key = _9p_owner_value_hash_func; 00596 nfs_param._9p_owner_hash_param.hash_func_rbt = _9p_owner_rbt_hash_func; 00597 nfs_param._9p_owner_hash_param.compare_key = compare_9p_owner_key; 00598 nfs_param._9p_owner_hash_param.key_to_str = display_9p_owner_key; 00599 nfs_param._9p_owner_hash_param.val_to_str = display_9p_owner_val; 00600 nfs_param._9p_owner_hash_param.ht_name = "9P Owner"; 00601 #endif 00602 00603 /* Cache inode parameters : hash table */ 00604 cache_inode_params.hparam.index_size = PRIME_CACHE_INODE; 00605 cache_inode_params.hparam.alphabet_length = 10; 00606 cache_inode_params.hparam.hash_func_key = NULL; 00607 cache_inode_params.hparam.hash_func_rbt = NULL; 00608 cache_inode_params.hparam.hash_func_both = cache_inode_fsal_rbt_both; 00609 cache_inode_params.hparam.compare_key = cache_inode_compare_key_fsal; 00610 cache_inode_params.hparam.key_to_str = display_cache; 00611 cache_inode_params.hparam.val_to_str = display_cache; 00612 cache_inode_params.hparam.ht_name = "Cache Inode"; 00613 cache_inode_params.hparam.flags = HT_FLAG_CACHE; 00614 cache_inode_params.hparam.ht_log_component = COMPONENT_CACHE_INODE; 00615 00616 #ifdef _USE_NLM 00617 /* Cache inode parameters : cookie hash table */ 00618 cache_inode_params.cookie_param.index_size = PRIME_STATE_ID; 00619 cache_inode_params.cookie_param.alphabet_length = 10; 00620 cache_inode_params.cookie_param.hash_func_key = lock_cookie_value_hash_func; 00621 cache_inode_params.cookie_param.hash_func_rbt = lock_cookie_rbt_hash_func ; 00622 cache_inode_params.cookie_param.compare_key = compare_lock_cookie_key; 00623 cache_inode_params.cookie_param.key_to_str = display_lock_cookie_key; 00624 cache_inode_params.cookie_param.val_to_str = display_lock_cookie_val; 00625 cache_inode_params.cookie_param.ht_name = "Lock Cookie"; 00626 cache_inode_params.cookie_param.flags = HT_FLAG_NONE; 00627 cache_inode_params.cookie_param.ht_log_component = COMPONENT_STATE; 00628 #endif 00629 00630 /* Cache inode parameters: Garbage collection policy */ 00631 cache_inode_gc_policy.entries_hwmark = 100000; 00632 cache_inode_gc_policy.entries_lwmark = 50000; 00633 cache_inode_gc_policy.use_fd_cache = TRUE; 00634 cache_inode_gc_policy.lru_run_interval = 600; 00635 cache_inode_gc_policy.fd_limit_percent = 99; 00636 cache_inode_gc_policy.fd_hwmark_percent = 90; 00637 cache_inode_gc_policy.fd_lwmark_percent = 50; 00638 cache_inode_gc_policy.reaper_work = 1000; 00639 cache_inode_gc_policy.biggest_window = 40; 00640 cache_inode_gc_policy.required_progress = 5; 00641 cache_inode_gc_policy.futility_count = 8; 00642 00643 cache_inode_params.grace_period_attr = 0; 00644 cache_inode_params.grace_period_link = 0; 00645 cache_inode_params.grace_period_dirent = 0; 00646 cache_inode_params.expire_type_attr = CACHE_INODE_EXPIRE_NEVER; 00647 cache_inode_params.expire_type_link = CACHE_INODE_EXPIRE_NEVER; 00648 cache_inode_params.expire_type_dirent = CACHE_INODE_EXPIRE_NEVER; 00649 cache_inode_params.use_test_access = 1; 00650 cache_inode_params.getattr_dir_invalidation = 0; 00651 #ifdef _USE_NFS4_ACL 00652 cache_inode_params.attrmask = FSAL_ATTR_MASK_V4; 00653 #else 00654 cache_inode_params.attrmask = FSAL_ATTR_MASK_V2_V3; 00655 #endif 00656 cache_inode_params.use_fsal_hash = 1; 00657 00658 /* FSAL parameters */ 00659 nfs_param.fsal_param.fsal_info.max_fs_calls = 30; /* No semaphore to access the FSAL */ 00660 00661 FSAL_SetDefault_FSAL_parameter(&nfs_param.fsal_param); 00662 FSAL_SetDefault_FS_common_parameter(&nfs_param.fsal_param); 00663 FSAL_SetDefault_FS_specific_parameter(&nfs_param.fsal_param); 00664 00665 nfs_param.pexportlist = NULL; 00666 00667 /* SNMP ADM parameters */ 00668 #ifdef _SNMP_ADM_ACTIVE 00669 strcpy(nfs_param.extern_param.snmp_adm.snmp_agentx_socket, ""); 00670 nfs_param.extern_param.snmp_adm.product_id = 1; 00671 strcpy(nfs_param.extern_param.snmp_adm.snmp_log_file, ""); 00672 00673 nfs_param.extern_param.snmp_adm.export_cache_stats = TRUE; 00674 nfs_param.extern_param.snmp_adm.export_requests_stats = TRUE; 00675 nfs_param.extern_param.snmp_adm.export_maps_stats = FALSE; 00676 nfs_param.extern_param.snmp_adm.export_nfs_calls_detail = FALSE; 00677 nfs_param.extern_param.snmp_adm.export_fsal_calls_detail = FALSE; 00678 #endif 00679 } /* nfs_set_param_default */ 00680 00685 int nfs_set_param_from_conf(nfs_start_info_t * p_start_info) 00686 { 00687 config_file_t config_struct; 00688 int rc; 00689 fsal_status_t fsal_status; 00690 cache_inode_status_t cache_inode_status; 00691 00692 /* First, parse the configuration file */ 00693 00694 config_struct = config_ParseFile(config_path); 00695 00696 if(!config_struct) 00697 { 00698 LogFatal(COMPONENT_INIT, "Error while parsing %s: %s", 00699 config_path, config_GetErrorMsg()); 00700 } 00701 00702 /* Core parameters */ 00703 if((rc = nfs_read_core_conf(config_struct, &nfs_param.core_param)) < 0) 00704 { 00705 LogCrit(COMPONENT_INIT, 00706 "Error while parsing core configuration"); 00707 return -1; 00708 } 00709 else 00710 { 00711 /* No such stanza in configuration file */ 00712 if(rc == 1) 00713 LogCrit(COMPONENT_INIT, 00714 "No core configuration found in config file, using default"); 00715 else 00716 LogDebug(COMPONENT_INIT, 00717 "core configuration read from config file"); 00718 } 00719 00720 /* Load FSAL configuration from parsed file */ 00721 fsal_status = 00722 FSAL_load_FSAL_parameter_from_conf(config_struct, &nfs_param.fsal_param); 00723 if(FSAL_IS_ERROR(fsal_status)) 00724 { 00725 if(fsal_status.major == ERR_FSAL_NOENT) 00726 LogDebug(COMPONENT_INIT, 00727 "No FSAL parameters found in config file, using default"); 00728 else 00729 { 00730 LogCrit(COMPONENT_INIT, "Error while parsing FSAL parameters"); 00731 LogError(COMPONENT_INIT, ERR_FSAL, fsal_status.major, fsal_status.minor); 00732 return -1; 00733 } 00734 } 00735 else 00736 LogDebug(COMPONENT_INIT, 00737 "FSAL parameters read from config file"); 00738 00739 /* Load FSAL configuration from parsed file */ 00740 fsal_status = 00741 FSAL_load_FS_common_parameter_from_conf(config_struct, &nfs_param.fsal_param); 00742 if(FSAL_IS_ERROR(fsal_status)) 00743 { 00744 if(fsal_status.major == ERR_FSAL_NOENT) 00745 LogDebug(COMPONENT_INIT, 00746 "No FS common configuration found in config file, using default"); 00747 else 00748 { 00749 LogCrit(COMPONENT_INIT, 00750 "Error while parsing FS common configuration"); 00751 LogError(COMPONENT_INIT, ERR_FSAL, fsal_status.major, fsal_status.minor); 00752 return -1; 00753 } 00754 } 00755 else 00756 LogDebug(COMPONENT_INIT, 00757 "FS comon configuration read from config file"); 00758 00759 /* Load FSAL configuration from parsed file */ 00760 fsal_status = 00761 FSAL_load_FS_specific_parameter_from_conf(config_struct, &nfs_param.fsal_param); 00762 if(FSAL_IS_ERROR(fsal_status)) 00763 { 00764 if(fsal_status.major == ERR_FSAL_NOENT) 00765 LogDebug(COMPONENT_INIT, 00766 "No FS specific configuration found in config file, using default"); 00767 else 00768 { 00769 LogCrit(COMPONENT_INIT, 00770 "Error while parsing FS specific configuration"); 00771 LogError(COMPONENT_INIT, ERR_FSAL, fsal_status.major, fsal_status.minor); 00772 return -1; 00773 } 00774 } 00775 else 00776 LogDebug(COMPONENT_INIT, 00777 "FS specific configuration read from config file"); 00778 00779 /* Workers parameters */ 00780 if((rc = nfs_read_worker_conf(config_struct, &nfs_param.worker_param)) < 0) 00781 { 00782 LogCrit(COMPONENT_INIT, 00783 "Error while parsing workers configuration"); 00784 return -1; 00785 } 00786 else 00787 { 00788 /* No such stanza in configuration file */ 00789 if(rc == 1) 00790 LogDebug(COMPONENT_INIT, 00791 "No workers configuration found in config file, using default"); 00792 else 00793 LogDebug(COMPONENT_INIT, 00794 "workers configuration read from config file"); 00795 } 00796 00797 /* Worker parameters : dupreq hash table */ 00798 if((rc = nfs_read_dupreq_hash_conf(config_struct, &nfs_param.dupreq_param)) < 0) 00799 { 00800 LogCrit(COMPONENT_INIT, 00801 "Error while parsing duplicate request hash table configuration"); 00802 return -1; 00803 } 00804 else 00805 { 00806 /* No such stanza in configuration file */ 00807 if(rc == 1) 00808 LogDebug(COMPONENT_INIT, 00809 "No duplicate request hash table configuration found in config file, using default"); 00810 else 00811 LogDebug(COMPONENT_INIT, 00812 "duplicate request hash table configuration read from config file"); 00813 } 00814 00815 /* Worker paramters: ip/name hash table and expiration for each entry */ 00816 if((rc = nfs_read_ip_name_conf(config_struct, &nfs_param.ip_name_param)) < 0) 00817 { 00818 LogCrit(COMPONENT_INIT, 00819 "Error while parsing IP/name configuration"); 00820 return -1; 00821 } 00822 else 00823 { 00824 /* No such stanza in configuration file */ 00825 if(rc == 1) 00826 LogDebug(COMPONENT_INIT, 00827 "No IP/name configuration found in config file, using default"); 00828 else 00829 LogDebug(COMPONENT_INIT, 00830 "IP/name configuration read from config file"); 00831 } 00832 00833 /* Worker paramters: uid_mapper hash table, same config for uid and uname resolution */ 00834 if(((rc = nfs_read_uidmap_conf(config_struct, &nfs_param.uidmap_cache_param)) < 0) 00835 || ((rc = nfs_read_uidmap_conf(config_struct, &nfs_param.unamemap_cache_param)) < 00836 0)) 00837 { 00838 LogCrit(COMPONENT_INIT, 00839 "Error while parsing UID_MAPPER configuration"); 00840 return -1; 00841 } 00842 else 00843 { 00844 /* No such stanza in configuration file */ 00845 if(rc == 1) 00846 LogDebug(COMPONENT_INIT, 00847 "No UID_MAPPER configuration found in config file, using default"); 00848 else 00849 LogDebug(COMPONENT_INIT, 00850 "UID_MAPPER configuration read from config file"); 00851 } 00852 00853 /* Worker paramters: gid_mapper hash table, same config for gid and gname resolution */ 00854 if(((rc = nfs_read_gidmap_conf(config_struct, &nfs_param.gidmap_cache_param)) < 0) 00855 || ((rc = nfs_read_gidmap_conf(config_struct, &nfs_param.gnamemap_cache_param)) < 00856 0)) 00857 { 00858 LogCrit(COMPONENT_INIT, 00859 "Error while parsing GID_MAPPER configuration"); 00860 return -1; 00861 } 00862 else 00863 { 00864 /* No such stanza in configuration file */ 00865 if(rc == 1) 00866 LogDebug(COMPONENT_INIT, 00867 "No GID_MAPPER configuration found in config file, using default"); 00868 else 00869 LogDebug(COMPONENT_INIT, 00870 "GID_MAPPER configuration read from config file"); 00871 } 00872 00873 /* Worker paramters: client_id hash table */ 00874 if((rc = nfs_read_client_id_conf(config_struct, &nfs_param.client_id_param)) < 0) 00875 { 00876 LogCrit(COMPONENT_INIT, 00877 "Error while parsing Client id configuration"); 00878 return -1; 00879 } 00880 else 00881 { 00882 /* No such stanza in configuration file */ 00883 if(rc == 1) 00884 LogDebug(COMPONENT_INIT, 00885 "No Client id configuration found in config file, using default"); 00886 else 00887 LogDebug(COMPONENT_INIT, 00888 "Client id configuration read from config file"); 00889 } 00890 00891 /* Worker paramters: state_id hash table */ 00892 if((rc = nfs_read_state_id_conf(config_struct, &nfs_param.state_id_param)) < 0) 00893 { 00894 LogCrit(COMPONENT_INIT, 00895 "Error while parsing State id configuration"); 00896 return -1; 00897 } 00898 else 00899 { 00900 /* No such stanza in configuration file */ 00901 if(rc == 1) 00902 LogDebug(COMPONENT_INIT, 00903 "No state id configuration found in config file, using default"); 00904 else 00905 LogDebug(COMPONENT_INIT, 00906 "state id configuration read from config file"); 00907 } 00908 00909 #ifdef _USE_NFS4_1 00910 /* Worker paramters: session_id hash table */ 00911 if((rc = nfs_read_session_id_conf(config_struct, &nfs_param.session_id_param)) < 0) 00912 { 00913 LogCrit(COMPONENT_INIT, 00914 "Error while parsing session id configuration"); 00915 return -1; 00916 } 00917 else 00918 { 00919 /* No such stanza in configuration file */ 00920 if(rc == 1) 00921 LogDebug(COMPONENT_INIT, 00922 "No session id configuration found in config file, using default"); 00923 else 00924 LogDebug(COMPONENT_INIT, 00925 "session id configuration read from config file"); 00926 } 00927 00928 #endif /* _USE_NFS4_1 */ 00929 00930 #ifdef _HAVE_GSSAPI 00931 /* NFS kerberos5 configuration */ 00932 if((rc = nfs_read_krb5_conf(config_struct, &nfs_param.krb5_param)) < 0) 00933 { 00934 LogCrit(COMPONENT_INIT, 00935 "Error while parsing NFS/KRB5 configuration for RPCSEC_GSS"); 00936 return -1; 00937 } 00938 else 00939 { 00940 /* No such stanza in configuration file */ 00941 if(rc == 1) 00942 LogDebug(COMPONENT_INIT, 00943 "No NFS/KRB5 configuration found in config file, using default"); 00944 else 00945 LogDebug(COMPONENT_INIT, 00946 "NFS/KRB5 configuration read from config file"); 00947 } 00948 #endif 00949 00950 /* NFSv4 specific configuration */ 00951 if((rc = nfs_read_version4_conf(config_struct, &nfs_param.nfsv4_param)) < 0) 00952 { 00953 LogCrit(COMPONENT_INIT, 00954 "Error while parsing NFSv4 specific configuration"); 00955 return -1; 00956 } 00957 else 00958 { 00959 /* No such stanza in configuration file */ 00960 if(rc == 1) 00961 LogDebug(COMPONENT_INIT, 00962 "No NFSv4 specific configuration found in config file, using default"); 00963 else 00964 LogDebug(COMPONENT_INIT, 00965 "NFSv4 specific configuration read from config file"); 00966 } 00967 00968 #ifdef _USE_9P 00969 if( ( rc = _9p_read_conf( config_struct, 00970 &nfs_param._9p_param ) ) < 0 ) 00971 { 00972 if( rc == -2 ) 00973 LogDebug(COMPONENT_INIT, 00974 "No 9P configuration found, using default"); 00975 else 00976 { 00977 LogCrit( COMPONENT_INIT, 00978 "Error while parsing 9P configuration" ) ; 00979 return -1 ; 00980 } 00981 } 00982 #endif 00983 00984 /* Cache inode parameters : hash table */ 00985 if((cache_inode_status = 00986 cache_inode_read_conf_hash_parameter(config_struct, 00987 &cache_inode_params)) 00988 != CACHE_INODE_SUCCESS) 00989 { 00990 if(cache_inode_status == CACHE_INODE_NOT_FOUND) 00991 LogDebug(COMPONENT_INIT, 00992 "No Cache Inode Hash Table configuration found, using default"); 00993 else 00994 { 00995 LogCrit(COMPONENT_INIT, 00996 "Error while parsing Cache Inode Hash Table configuration"); 00997 return -1; 00998 } 00999 } 01000 else 01001 LogDebug(COMPONENT_INIT, 01002 "Cache Inode Hash Table configuration read from config file"); 01003 01004 /* Cache inode parameters : Garbage collection policy */ 01005 if((cache_inode_status = 01006 cache_inode_read_conf_gc_policy(config_struct, 01007 &cache_inode_gc_policy)) != 01008 CACHE_INODE_SUCCESS) 01009 { 01010 if(cache_inode_status == CACHE_INODE_NOT_FOUND) 01011 LogDebug(COMPONENT_INIT, 01012 "No Cache Inode Garbage Collection Policy configuration found, using default"); 01013 else 01014 { 01015 LogCrit(COMPONENT_INIT, 01016 "Error while parsing Cache Inode Garbage Collection Policy configuration"); 01017 return -1; 01018 } 01019 } 01020 else 01021 LogDebug(COMPONENT_INIT, 01022 "Cache Inode Garbage Collection Policy configuration read from config file"); 01023 01024 /* Cache inode client parameters */ 01025 if((cache_inode_status 01026 = cache_inode_read_conf_parameter(config_struct, 01027 &cache_inode_params)) 01028 != CACHE_INODE_SUCCESS) 01029 { 01030 if(cache_inode_status == CACHE_INODE_NOT_FOUND) 01031 LogDebug(COMPONENT_INIT, 01032 "No Cache Inode Client configuration found, using default"); 01033 else 01034 { 01035 LogCrit(COMPONENT_INIT, 01036 "Error while parsing Cache Inode Client configuration"); 01037 return 1; 01038 } 01039 } 01040 else 01041 LogDebug(COMPONENT_INIT, 01042 "Cache Inode Client configuration read from config file"); 01043 01044 #ifdef _SNMP_ADM_ACTIVE 01045 if(get_snmpadm_conf(config_struct, &nfs_param.extern_param) != 0) 01046 { 01047 LogCrit(COMPONENT_INIT, 01048 "Error loading SNMP_ADM configuration"); 01049 return -1; 01050 } 01051 else 01052 { 01053 LogDebug(COMPONENT_INIT, 01054 "snmp_adm configuration read from config file"); 01055 } 01056 #endif /* _SNMP_ADM_ACTIVE */ 01057 01058 #ifdef _USE_STAT_EXPORTER 01059 if(get_stat_exporter_conf(config_struct, &nfs_param.extern_param) != 0) 01060 { 01061 LogCrit(COMPONENT_INIT, 01062 "Error loading STAT_EXPORTER configuration"); 01063 return -1; 01064 } 01065 else 01066 LogDebug(COMPONENT_INIT, 01067 "STAT_EXPORTER configuration read from config file"); 01068 #endif /* _USE_STAT_EXPORTER */ 01069 01070 /* Load export entries from parsed file 01071 * returns the number of export entries. 01072 */ 01073 rc = ReadExports(config_struct, &nfs_param.pexportlist); 01074 if(rc < 0) 01075 { 01076 LogCrit(COMPONENT_INIT, 01077 "Error while parsing export entries"); 01078 return -1; 01079 } 01080 else if(rc == 0) 01081 { 01082 LogWarn(COMPONENT_INIT, 01083 "No export entries found in configuration file !!!"); 01084 } 01085 01086 LogEvent(COMPONENT_INIT, "Configuration file successfully parsed"); 01087 01088 /* freeing syntax tree : */ 01089 01090 config_Free(config_struct); 01091 01092 return 0; 01093 } 01094 01098 static int is_prime (int v) 01099 { 01100 int i, m; 01101 01102 if (v <= 1) 01103 return FALSE; 01104 if (v == 2) 01105 return TRUE; 01106 if (v % 2 == 0) 01107 return FALSE; 01108 // dont link with libm just for this 01109 #ifdef LINK_LIBM 01110 m = (int)sqrt(v); 01111 #else 01112 m = v; 01113 #endif 01114 for (i = 2 ; i <= m; i +=2) { 01115 if (v % i == 0) 01116 return FALSE; 01117 } 01118 return TRUE; 01119 } 01120 01125 int nfs_check_param_consistency() 01126 { 01127 01130 if(nfs_param.core_param.nb_worker <= 0) 01131 { 01132 LogCrit(COMPONENT_INIT, 01133 "BAD PARAMETER: There must be more than %d workers", 01134 nfs_param.core_param.nb_worker); 01135 return 1; 01136 } 01137 01138 if(nfs_param.core_param.nb_worker > NB_MAX_WORKER_THREAD) 01139 { 01140 LogCrit(COMPONENT_INIT, 01141 "BAD PARAMETER: number of workers is limited to %d", 01142 NB_MAX_WORKER_THREAD); 01143 return 1; 01144 } 01145 01146 #if 0 01147 /* XXXX this seems somewhat the obvious of what I would have reasoned. 01148 * Where we had a thread for every connection (but sharing a single 01149 * fdset for select), dispatching on a small, fixed worker pool, we 01150 * now had an arbitrary, fixed work pool, with flexible event 01151 * channels. 01152 */ 01153 if (2*nfs_param.core_param.nb_worker > 01154 nfs_param.cache_layers_param.cache_param.hparam.index_size ) 01155 { 01156 LogCrit(COMPONENT_INIT, 01157 "BAD PARAMETER: number of workers is too large compared to " 01158 "Cache_Inode's index size, it should be smaller than " 01159 "half of it"); 01160 return 1; 01161 } 01162 #endif 01163 01164 // check for parameters which need to be primes 01165 if (!is_prime(nfs_param.dupreq_param.hash_param.index_size) || 01166 #ifdef _HAVE_GSSAPI 01167 !is_prime(nfs_param.krb5_param.hash_param.index_size) || 01168 #endif 01169 !is_prime(nfs_param.ip_name_param.hash_param.index_size) || 01170 !is_prime(nfs_param.uidmap_cache_param.hash_param.index_size) || 01171 !is_prime(nfs_param.unamemap_cache_param.hash_param.index_size) || 01172 !is_prime(nfs_param.gidmap_cache_param.hash_param.index_size) || 01173 !is_prime(nfs_param.uidgidmap_cache_param.hash_param.index_size) || 01174 !is_prime(nfs_param.gnamemap_cache_param.hash_param.index_size) || 01175 !is_prime(nfs_param.ip_stats_param.hash_param.index_size) || 01176 !is_prime(nfs_param.client_id_param.cid_unconfirmed_hash_param.index_size) || 01177 !is_prime(nfs_param.client_id_param.cid_confirmed_hash_param.index_size) || 01178 !is_prime(nfs_param.client_id_param.cr_hash_param.index_size) || 01179 !is_prime(nfs_param.state_id_param.hash_param.index_size) || 01180 #ifdef _USE_NFS4_1 01181 !is_prime(nfs_param.session_id_param.hash_param.index_size) || 01182 #endif 01183 !is_prime(nfs_param.nfs4_owner_param.hash_param.index_size) || 01184 #ifdef _USE_NLM 01185 !is_prime(nfs_param.nsm_client_hash_param.index_size) || 01186 !is_prime(nfs_param.nlm_client_hash_param.index_size) || 01187 !is_prime(nfs_param.nlm_owner_hash_param.index_size) || 01188 !is_prime(cache_inode_params.cookie_param.index_size) || 01189 #endif 01190 !is_prime(cache_inode_params.hparam.index_size)) 01191 { 01192 LogCrit(COMPONENT_INIT, "BAD PARAMETER(s) : expected primes"); 01193 } 01194 01195 return 0; 01196 } 01197 01198 void nfs_reset_stats(void) 01199 { 01200 unsigned int i = 0; 01201 unsigned int j = 0; 01202 01203 for(i = 0; i < nfs_param.core_param.nb_worker; i++) 01204 { 01205 workers_data[i].stats.nb_total_req = 0; 01206 workers_data[i].stats.nb_udp_req = 0; 01207 workers_data[i].stats.nb_tcp_req = 0; 01208 workers_data[i].stats.stat_req.nb_mnt1_req = 0; 01209 workers_data[i].stats.stat_req.nb_mnt3_req = 0; 01210 workers_data[i].stats.stat_req.nb_nfs2_req = 0; 01211 workers_data[i].stats.stat_req.nb_nfs3_req = 0; 01212 workers_data[i].stats.stat_req.nb_nfs4_req = 0; 01213 01214 for(j = 0; j < MNT_V1_NB_COMMAND; j++) 01215 { 01216 workers_data[i].stats.stat_req.stat_req_mnt1[j].total = 0; 01217 workers_data[i].stats.stat_req.stat_req_mnt1[j].success = 0; 01218 workers_data[i].stats.stat_req.stat_req_mnt1[j].dropped = 0; 01219 01220 } 01221 01222 for(j = 0; j < MNT_V3_NB_COMMAND; j++) 01223 { 01224 workers_data[i].stats.stat_req.stat_req_mnt3[j].total = 0; 01225 workers_data[i].stats.stat_req.stat_req_mnt3[j].success = 0; 01226 workers_data[i].stats.stat_req.stat_req_mnt3[j].dropped = 0; 01227 } 01228 01229 for(j = 0; j < NFS_V2_NB_COMMAND; j++) 01230 { 01231 workers_data[i].stats.stat_req.stat_req_nfs2[j].total = 0; 01232 workers_data[i].stats.stat_req.stat_req_nfs2[j].success = 0; 01233 workers_data[i].stats.stat_req.stat_req_nfs2[j].dropped = 0; 01234 } 01235 01236 for(j = 0; j < NFS_V3_NB_COMMAND; j++) 01237 { 01238 workers_data[i].stats.stat_req.stat_req_nfs3[j].total = 0; 01239 workers_data[i].stats.stat_req.stat_req_nfs3[j].success = 0; 01240 workers_data[i].stats.stat_req.stat_req_nfs3[j].dropped = 0; 01241 } 01242 01243 for(j = 0; j < NFS_V4_NB_COMMAND; j++) 01244 { 01245 workers_data[i].stats.stat_req.stat_req_nfs4[j].total = 0; 01246 workers_data[i].stats.stat_req.stat_req_nfs4[j].success = 0; 01247 workers_data[i].stats.stat_req.stat_req_nfs4[j].dropped = 0; 01248 } 01249 01250 for(j = 0; j < NFS_V40_NB_OPERATION; j++) 01251 { 01252 workers_data[i].stats.stat_req.stat_op_nfs40[j].total = 0; 01253 workers_data[i].stats.stat_req.stat_op_nfs40[j].success = 0; 01254 workers_data[i].stats.stat_req.stat_op_nfs40[j].failed = 0; 01255 } 01256 01257 for(j = 0; j < NFS_V41_NB_OPERATION; j++) 01258 { 01259 workers_data[i].stats.stat_req.stat_op_nfs41[j].total = 0; 01260 workers_data[i].stats.stat_req.stat_op_nfs41[j].success = 0; 01261 workers_data[i].stats.stat_req.stat_op_nfs41[j].failed = 0; 01262 } 01263 01264 workers_data[i].stats.last_stat_update = 0; 01265 memset(&workers_data[i].stats.fsal_stats, 0, sizeof(fsal_statistics_t)); 01266 } /* for( i = 0 ; i < nfs_param.core_param.nb_worker ; i++ ) */ 01267 01268 } /* void nfs_reset_stats( void ) */ 01269 01270 static void nfs_Start_threads(void) 01271 { 01272 int rc = 0; 01273 pthread_attr_t attr_thr; 01274 unsigned long i = 0; 01275 01276 LogDebug(COMPONENT_THREAD, 01277 "Starting threads"); 01278 01279 /* Init for thread parameter (mostly for scheduling) */ 01280 if(pthread_attr_init(&attr_thr) != 0) 01281 LogDebug(COMPONENT_THREAD, "can't init pthread's attributes"); 01282 01283 if(pthread_attr_setscope(&attr_thr, PTHREAD_SCOPE_SYSTEM) != 0) 01284 LogDebug(COMPONENT_THREAD, "can't set pthread's scope"); 01285 01286 if(pthread_attr_setdetachstate(&attr_thr, PTHREAD_CREATE_JOINABLE) != 0) 01287 LogDebug(COMPONENT_THREAD, "can't set pthread's join state"); 01288 01289 if(pthread_attr_setstacksize(&attr_thr, THREAD_STACK_SIZE) != 0) 01290 LogDebug(COMPONENT_THREAD, "can't set pthread's stack size"); 01291 01292 /* Initialisation of Threads's fridge */ 01293 if( fridgethr_init() != 0 ) 01294 { 01295 LogFatal(COMPONENT_THREAD, "can't run fridgethr_init"); 01296 } 01297 01298 /* Starting the thread dedicated to signal handling */ 01299 if( ( rc = pthread_create( &sigmgr_thrid, &attr_thr, sigmgr_thread, NULL ) ) != 0 ) 01300 { 01301 LogFatal(COMPONENT_THREAD, 01302 "Could not create sigmgr_thread, error = %d (%s)", 01303 errno, strerror(errno)); 01304 } 01305 LogDebug(COMPONENT_THREAD, 01306 "sigmgr thread started"); 01307 01308 /* Starting all of the worker thread */ 01309 for(i = 0; i < nfs_param.core_param.nb_worker; i++) 01310 { 01311 if((rc = 01312 pthread_create(&(worker_thrid[i]), &attr_thr, worker_thread, (void *)i)) != 0) 01313 { 01314 LogFatal(COMPONENT_THREAD, 01315 "Could not create worker_thread #%lu, error = %d (%s)", 01316 i, errno, strerror(errno)); 01317 } 01318 } 01319 LogEvent(COMPONENT_THREAD, 01320 "%d worker threads were started successfully", 01321 nfs_param.core_param.nb_worker); 01322 01323 #ifdef _USE_BLOCKING_LOCKS 01324 /* Start State Async threads */ 01325 state_async_thread_start(); 01326 #endif 01327 01328 /* 01329 * Now that all TCB controlled threads (workers, NLM, 01330 * sigmgr) were created, lets wait for them to fully 01331 * initialze __before__ we create the threads that listen 01332 * for incoming requests. 01333 */ 01334 wait_for_threads_to_awaken(); 01335 01336 /* Start event channel service threads */ 01337 nfs_rpc_dispatch_threads(&attr_thr); 01338 01339 #ifdef _USE_9P 01340 /* Starting the 9p dispatcher thread */ 01341 if((rc = pthread_create(&_9p_dispatcher_thrid, &attr_thr, 01342 _9p_dispatcher_thread, NULL ) ) != 0 ) 01343 { 01344 LogFatal(COMPONENT_THREAD, 01345 "Could not create 9p dispatcher_thread, error = %d (%s)", 01346 errno, strerror(errno)); 01347 } 01348 LogEvent(COMPONENT_THREAD, "9p dispatcher thread was started successfully"); 01349 #endif 01350 01351 #ifdef USE_DBUS 01352 /* DBUS event thread */ 01353 if((rc = pthread_create(&gsh_dbus_thrid, &attr_thr, gsh_dbus_thread, 01354 NULL ) ) != 0 ) 01355 { 01356 LogFatal(COMPONENT_THREAD, 01357 "Could not create gsh_dbus_thread, error = %d (%s)", 01358 errno, strerror(errno)); 01359 } 01360 LogEvent(COMPONENT_THREAD, "gsh_dbusthread was started successfully"); 01361 #endif 01362 01363 /* Starting the admin thread */ 01364 if((rc = pthread_create(&admin_thrid, &attr_thr, admin_thread, NULL)) != 0) 01365 { 01366 LogFatal(COMPONENT_THREAD, 01367 "Could not create admin_thread, error = %d (%s)", 01368 errno, strerror(errno)); 01369 } 01370 LogEvent(COMPONENT_THREAD, "admin thread was started successfully"); 01371 01372 /* Starting the stats thread */ 01373 if((rc = 01374 pthread_create(&stat_thrid, &attr_thr, stats_thread, NULL)) != 0) 01375 { 01376 LogFatal(COMPONENT_THREAD, 01377 "Could not create stats_thread, error = %d (%s)", 01378 errno, strerror(errno)); 01379 } 01380 LogEvent(COMPONENT_THREAD, "statistics thread was started successfully"); 01381 01382 #ifdef _USE_STAT_EXPORTER 01383 01384 /* Starting the long processing threshold thread */ 01385 if((rc = 01386 pthread_create(&stat_thrid, &attr_thr, long_processing_thread, NULL)) != 0) 01387 { 01388 LogFatal(COMPONENT_THREAD, 01389 "Could not create long_processing_thread, error = %d (%s)", 01390 errno, strerror(errno)); 01391 } 01392 LogEvent(COMPONENT_THREAD, 01393 "long processing threshold thread was started successfully"); 01394 01395 /* Starting the stat exporter thread */ 01396 if((rc = 01397 pthread_create(&stat_exporter_thrid, &attr_thr, stat_exporter_thread, NULL)) != 0) 01398 { 01399 LogFatal(COMPONENT_THREAD, 01400 "Could not create stat_exporter_thread, error = %d (%s)", 01401 errno, strerror(errno)); 01402 } 01403 LogEvent(COMPONENT_THREAD, 01404 "statistics exporter thread was started successfully"); 01405 01406 #endif /* _USE_STAT_EXPORTER */ 01407 01408 /* Starting the reaper thread */ 01409 if((rc = 01410 pthread_create(&reaper_thrid, &attr_thr, reaper_thread, NULL)) != 0) 01411 { 01412 LogFatal(COMPONENT_THREAD, 01413 "Could not create reaper_thread, error = %d (%s)", 01414 errno, strerror(errno)); 01415 } 01416 LogEvent(COMPONENT_THREAD, 01417 "reaper thread was started successfully"); 01418 01419 #ifdef _USE_UPCALL_SIMULATOR 01420 /* Starts the thread that mimics upcalls from the FSAL */ 01421 /* Starting the stats thread */ 01422 if((rc = 01423 pthread_create(&upcall_simulator_thrid, &attr_thr, upcall_simulator_thread, NULL)) != 0) 01424 { 01425 LogFatal(COMPONENT_THREAD, 01426 "Could not create upcall_simulator_thread, error = %d (%s)", 01427 errno, strerror(errno)); 01428 } 01429 LogEvent(COMPONENT_THREAD, "upcall_simulator thread was started successfully"); 01430 #endif 01431 01432 #ifdef _USE_FSAL_UP 01433 /* Starting the fsal_up_process thread */ 01434 if((rc = 01435 pthread_create(&upp_thrid, &attr_thr, fsal_up_process_thread, NULL)) != 0) 01436 { 01437 LogFatal(COMPONENT_THREAD, 01438 "Could not create fsal_up_process_thread, error = %d (%s)", 01439 errno, strerror(errno)); 01440 } 01441 LogEvent(COMPONENT_THREAD, 01442 "fsal_up_process_thread was started successfully"); 01443 01444 create_fsal_up_threads(); 01445 #endif /* _USE_FSAL_UP */ 01446 01447 } /* nfs_Start_threads */ 01448 01460 static void nfs_Init(const nfs_start_info_t * p_start_info) 01461 { 01462 cache_inode_status_t cache_status; 01463 state_status_t state_status; 01464 fsal_status_t fsal_status; 01465 unsigned int i = 0; 01466 int rc = 0; 01467 #ifdef _HAVE_GSSAPI 01468 gss_buffer_desc gss_service_buf; 01469 OM_uint32 maj_stat, min_stat; 01470 char GssError[MAXNAMLEN]; 01471 #endif 01472 01473 /* FSAL Initialisation */ 01474 fsal_status = FSAL_Init(&nfs_param.fsal_param); 01475 if(FSAL_IS_ERROR(fsal_status)) 01476 { 01477 /* Failed init */ 01478 LogFatal(COMPONENT_INIT, "FSAL library could not be initialized"); 01479 } 01480 LogInfo(COMPONENT_INIT, "FSAL library successfully initialized"); 01481 01482 #ifdef USE_DBUS 01483 /* DBUS init */ 01484 gsh_dbus_pkginit(); 01485 #endif 01486 01487 /* Cache Inode Initialisation */ 01488 if((fh_to_cache_entry_ht = 01489 cache_inode_init(cache_inode_params, &cache_status)) == NULL) 01490 { 01491 LogFatal(COMPONENT_INIT, 01492 "Cache Inode Layer could not be initialized, status=%s", 01493 cache_inode_err_str(cache_status)); 01494 } 01495 01496 /* Initialize thread control block */ 01497 tcb_head_init(); 01498 01499 #ifdef _USE_BLOCKING_LOCKS 01500 if(state_lock_init(&state_status, 01501 cache_inode_params.cookie_param) 01502 != STATE_SUCCESS) 01503 #else 01504 if(state_lock_init(&state_status) 01505 != STATE_SUCCESS) 01506 #endif 01507 { 01508 LogFatal(COMPONENT_INIT, 01509 "Cache Inode Layer could not be initialized, status=%s", 01510 state_err_str(state_status)); 01511 } 01512 LogInfo(COMPONENT_INIT, "Cache Inode library successfully initialized"); 01513 01514 /* Cache Inode LRU (call this here, rather than as part of 01515 cache_inode_init() so the GC policy has been set */ 01516 cache_inode_lru_pkginit(); 01517 01518 #ifdef _USE_NFS4_1 01519 nfs41_session_pool = pool_init("NFSv4.1 session pool", 01520 sizeof(nfs41_session_t), 01521 pool_basic_substrate, 01522 NULL, NULL, NULL); 01523 #endif /* _USE_NFS4_1 */ 01524 01525 request_pool = pool_init("Request pool", 01526 sizeof(request_data_t), 01527 pool_basic_substrate, 01528 NULL, 01529 constructor_request_data_t, 01530 NULL); 01531 if(!request_pool) 01532 { 01533 LogCrit(COMPONENT_INIT, 01534 "Error while allocating request pool"); 01535 LogError(COMPONENT_INIT, ERR_SYS, ERR_MALLOC, errno); 01536 Fatal(); 01537 } 01538 01539 request_data_pool = pool_init("Request Data Pool", 01540 sizeof(nfs_request_data_t), 01541 pool_basic_substrate, 01542 NULL, 01543 constructor_nfs_request_data_t, 01544 NULL); 01545 if(!request_data_pool) 01546 { 01547 LogCrit(COMPONENT_INIT, 01548 "Error while allocating request data pool"); 01549 LogError(COMPONENT_INIT, ERR_SYS, ERR_MALLOC, errno); 01550 Fatal(); 01551 } 01552 01553 dupreq_pool = pool_init("Duplicate Request Pool", 01554 sizeof(dupreq_entry_t), 01555 pool_basic_substrate, 01556 NULL, NULL, NULL); 01557 if(!(dupreq_pool)) 01558 { 01559 LogCrit(COMPONENT_INIT, 01560 "Error while allocating duplicate request pool"); 01561 LogError(COMPONENT_INIT, ERR_SYS, ERR_MALLOC, errno); 01562 Fatal(); 01563 } 01564 01565 ip_stats_pool = pool_init("IP Stats Cache Pool", 01566 sizeof(nfs_ip_stats_t), 01567 pool_basic_substrate, 01568 NULL, NULL, NULL); 01569 01570 if(!(ip_stats_pool)) 01571 { 01572 LogCrit(COMPONENT_INIT, 01573 "Error while allocating IP stats cache pool"); 01574 LogError(COMPONENT_INIT, ERR_SYS, ERR_MALLOC, errno); 01575 Fatal(); 01576 } 01577 01578 #ifdef _USE_ASYNC_CACHE_INODE 01579 /* Start the TAD and synclets for writeback cache inode */ 01580 cache_inode_async_init(nfs_param.cache_layers_param.cache_inode_client_param); 01581 #endif 01582 01583 /* If rpcsec_gss is used, set the path to the keytab */ 01584 #ifdef _HAVE_GSSAPI 01585 #ifdef HAVE_KRB5 01586 if(nfs_param.krb5_param.active_krb5) 01587 { 01588 OM_uint32 gss_status = GSS_S_COMPLETE; 01589 01590 if(nfs_param.krb5_param.keytab[0] != '\0') 01591 gss_status = krb5_gss_register_acceptor_identity(nfs_param.krb5_param.keytab); 01592 01593 if(gss_status != GSS_S_COMPLETE) 01594 { 01595 log_sperror_gss(GssError, gss_status, 0); 01596 LogFatal(COMPONENT_INIT, 01597 "Error setting krb5 keytab to value %s is %s", 01598 nfs_param.krb5_param.keytab, GssError); 01599 } 01600 LogInfo(COMPONENT_INIT, "krb5 keytab path successfully set to %s", 01601 nfs_param.krb5_param.keytab); 01602 #endif /* HAVE_KRB5 */ 01603 01604 /* Set up principal to be use for GSSAPPI within GSSRPC/KRB5 */ 01605 gss_service_buf.value = nfs_param.krb5_param.svc.principal; 01606 gss_service_buf.length = strlen(nfs_param.krb5_param.svc.principal) + 1; /* The '+1' is not to be forgotten, for the '\0' at the end */ 01607 01608 maj_stat = gss_import_name(&min_stat, 01609 &gss_service_buf, 01610 (gss_OID) GSS_C_NT_HOSTBASED_SERVICE, 01611 &nfs_param.krb5_param.svc.gss_name); 01612 if(maj_stat != GSS_S_COMPLETE) 01613 { 01614 log_sperror_gss(GssError, maj_stat, min_stat); 01615 LogFatal(COMPONENT_INIT, 01616 "Error importing gss principal %s is %s", 01617 nfs_param.krb5_param.svc.principal, GssError); 01618 } 01619 01620 if (nfs_param.krb5_param.svc.gss_name == GSS_C_NO_NAME) 01621 LogInfo(COMPONENT_INIT, "Regression: svc.gss_name == GSS_C_NO_NAME"); 01622 01623 LogInfo(COMPONENT_INIT, "gss principal \"%s\" successfully set", 01624 nfs_param.krb5_param.svc.principal); 01625 01626 /* Set the principal to GSSRPC */ 01627 if(!Svcauth_gss_set_svc_name(nfs_param.krb5_param.svc.gss_name)) 01628 { 01629 LogFatal(COMPONENT_INIT, "Impossible to set gss principal to GSSRPC"); 01630 } 01631 01632 /* Don't release name until shutdown, it will be used by the 01633 * backchannel. */ 01634 01635 /* Init the HashTable */ 01636 if(Gss_ctx_Hash_Init(nfs_param.krb5_param) == -1) 01637 { 01638 LogFatal(COMPONENT_INIT, "Impossible to init GSS CTX cache"); 01639 } 01640 else 01641 LogInfo(COMPONENT_INIT, "Gss Context Cache successfully initialized"); 01642 01643 #ifdef HAVE_KRB5 01644 } /* if( nfs_param.krb5_param.active_krb5 ) */ 01645 #endif /* HAVE_KRB5 */ 01646 #endif /* _HAVE_GSSAPI */ 01647 01648 /* RPC Initialisation - exits on failure*/ 01649 nfs_Init_svc(); 01650 LogInfo(COMPONENT_INIT, "RPC ressources successfully initialized"); 01651 01652 /* Worker initialisation */ 01653 if((workers_data = 01654 gsh_calloc(nfs_param.core_param.nb_worker, 01655 sizeof(nfs_worker_data_t))) == NULL) 01656 { 01657 LogError(COMPONENT_INIT, ERR_SYS, ERR_MALLOC, errno); 01658 Fatal(); 01659 } 01660 if(nfs_Init_gc_counter() != 0) 01661 { 01662 LogFatal(COMPONENT_INIT, "Error while initializing worker gc counter"); 01663 } 01664 LogDebug(COMPONENT_INIT, "worker gc counter successfully initialized"); 01665 01666 LogDebug(COMPONENT_INIT, "Initializing workers data structure"); 01667 01668 for(i = 0; i < nfs_param.core_param.nb_worker; i++) 01669 { 01670 char name[256]; 01671 01672 /* Set the index (mostly used for debug purpose */ 01673 workers_data[i].worker_index = i; 01674 01675 /* Fill in workers fields (semaphores and other stangenesses */ 01676 if(nfs_Init_worker_data(&(workers_data[i])) != 0) 01677 LogFatal(COMPONENT_INIT, 01678 "Error while initializing worker data #%d", i); 01679 01680 sprintf(name, "IP Stats for worker %d", i); 01681 nfs_param.ip_stats_param.hash_param.ht_name = gsh_strdup(name); 01682 ht_ip_stats[i] = nfs_Init_ip_stats(nfs_param.ip_stats_param); 01683 01684 if(ht_ip_stats[i] == NULL) 01685 LogFatal(COMPONENT_INIT, 01686 "Error while initializing IP/stats cache #%d", i); 01687 01688 workers_data[i].ht_ip_stats = ht_ip_stats[i]; 01689 LogDebug(COMPONENT_INIT, "worker data #%d successfully initialized", i); 01690 } /* for i */ 01691 01692 /* Admin initialisation */ 01693 nfs_Init_admin_data(); 01694 01695 /* Set the stats to zero */ 01696 nfs_reset_stats(); 01697 01698 /* Creates the pseudo fs */ 01699 LogDebug(COMPONENT_INIT, "Now building pseudo fs"); 01700 if((rc = nfs4_ExportToPseudoFS(nfs_param.pexportlist)) != 0) 01701 LogFatal(COMPONENT_INIT, 01702 "Error %d while initializing NFSv4 pseudo file system", rc); 01703 01704 LogInfo(COMPONENT_INIT, 01705 "NFSv4 pseudo file system successfully initialized"); 01706 01707 /* Init duplicate request cache */ 01708 LogDebug(COMPONENT_INIT, "Now building duplicate request hash table cache"); 01709 if((rc = nfs_Init_dupreq(nfs_param.dupreq_param)) != DUPREQ_SUCCESS) 01710 { 01711 LogFatal(COMPONENT_INIT, 01712 "Error %d while initializing duplicate request hash table cache", 01713 rc); 01714 } 01715 LogInfo(COMPONENT_INIT, 01716 "duplicate request hash table cache successfully initialized"); 01717 01718 /* Init the IP/name cache */ 01719 LogDebug(COMPONENT_INIT, "Now building IP/name cache"); 01720 if(nfs_Init_ip_name(nfs_param.ip_name_param) != IP_NAME_SUCCESS) 01721 { 01722 LogFatal(COMPONENT_INIT, 01723 "Error while initializing IP/name cache"); 01724 } 01725 LogInfo(COMPONENT_INIT, 01726 "IP/name cache successfully initialized"); 01727 01728 /* Init the UID_MAPPER cache */ 01729 LogDebug(COMPONENT_INIT, "Now building UID_MAPPER cache"); 01730 if((idmap_uid_init(nfs_param.uidmap_cache_param) != ID_MAPPER_SUCCESS) || 01731 (idmap_uname_init(nfs_param.unamemap_cache_param) != ID_MAPPER_SUCCESS)) 01732 { 01733 LogFatal(COMPONENT_INIT, 01734 "Error while initializing UID_MAPPER cache"); 01735 } 01736 LogInfo(COMPONENT_INIT, 01737 "UID_MAPPER cache successfully initialized"); 01738 01739 /* Init the UIDGID MAPPER Cache */ 01740 LogDebug(COMPONENT_INIT, 01741 "Now building UIDGID MAPPER Cache (for RPCSEC_GSS)"); 01742 if(uidgidmap_init(nfs_param.uidgidmap_cache_param) != ID_MAPPER_SUCCESS) 01743 { 01744 LogFatal(COMPONENT_INIT, 01745 "Error while initializing UIDGID_MAPPER cache"); 01746 } 01747 LogInfo(COMPONENT_INIT, 01748 "UIDGID_MAPPER cache successfully initialized"); 01749 01750 /* Init the GID_MAPPER cache */ 01751 LogDebug(COMPONENT_INIT, "Now building GID_MAPPER cache"); 01752 if((idmap_gid_init(nfs_param.gidmap_cache_param) != ID_MAPPER_SUCCESS) || 01753 (idmap_gname_init(nfs_param.gnamemap_cache_param) != ID_MAPPER_SUCCESS)) 01754 { 01755 LogFatal(COMPONENT_INIT, 01756 "Error while initializing GID_MAPPER cache"); 01757 } 01758 LogInfo(COMPONENT_INIT, 01759 "GID_MAPPER cache successfully initialized"); 01760 01761 /* Init the NFSv4 Clientid cache */ 01762 LogDebug(COMPONENT_INIT, "Now building NFSv4 clientid cache"); 01763 if(nfs_Init_client_id(&nfs_param.client_id_param) != CLIENT_ID_SUCCESS) 01764 { 01765 LogFatal(COMPONENT_INIT, 01766 "Error while initializing NFSv4 clientid cache"); 01767 } 01768 LogInfo(COMPONENT_INIT, 01769 "NFSv4 clientid cache successfully initialized"); 01770 01771 /* Init The NFSv4 State id cache */ 01772 LogDebug(COMPONENT_INIT, "Now building NFSv4 State Id cache"); 01773 if(nfs4_Init_state_id(nfs_param.state_id_param) != 0) 01774 { 01775 LogFatal(COMPONENT_INIT, 01776 "Error while initializing NFSv4 State Id cache"); 01777 } 01778 LogInfo(COMPONENT_INIT, 01779 "NFSv4 State Id cache successfully initialized"); 01780 01781 /* Init The NFSv4 Open Owner cache */ 01782 LogDebug(COMPONENT_INIT, "Now building NFSv4 Owner cache"); 01783 if(Init_nfs4_owner(nfs_param.nfs4_owner_param) != 0) 01784 { 01785 LogFatal(COMPONENT_INIT, 01786 "Error while initializing NFSv4 Owner cache"); 01787 } 01788 LogInfo(COMPONENT_INIT, 01789 "NFSv4 Open Owner cache successfully initialized"); 01790 01791 #ifdef _USE_NLM 01792 /* Init The NLM Owner cache */ 01793 LogDebug(COMPONENT_INIT, "Now building NLM Owner cache"); 01794 if(Init_nlm_hash() != 0) 01795 { 01796 LogFatal(COMPONENT_INIT, 01797 "Error while initializing NLM Owner cache"); 01798 } 01799 LogInfo(COMPONENT_INIT, 01800 "NLM Owner cache successfully initialized"); 01801 nlm_init(); 01802 #endif 01803 01804 #ifdef _USE_9P 01805 /* Init the 9P lock owner cache */ 01806 LogDebug(COMPONENT_INIT, "Now building 9P Owner cache"); 01807 if(Init_9p_hash() != 0) 01808 { 01809 LogFatal(COMPONENT_INIT, 01810 "Error while initializing 9P Owner cache"); 01811 } 01812 LogInfo(COMPONENT_INIT, 01813 "9P Owner cache successfully initialized"); 01814 #endif 01815 01816 #ifdef _USE_NFS4_1 01817 LogDebug(COMPONENT_INIT, "Now building NFSv4 Session Id cache"); 01818 if(nfs41_Init_session_id(nfs_param.session_id_param) != 0) 01819 { 01820 LogFatal(COMPONENT_INIT, 01821 "Error while initializing NFSv4 Session Id cache"); 01822 } 01823 LogInfo(COMPONENT_INIT, 01824 "NFSv4 Session Id cache successfully initialized"); 01825 #endif 01826 01827 #ifdef _USE_NFS4_ACL 01828 LogDebug(COMPONENT_INIT, "Now building NFSv4 ACL cache"); 01829 if(nfs4_acls_init() != 0) 01830 { 01831 LogCrit(COMPONENT_INIT, 01832 "Error while initializing NFSv4 ACLs"); 01833 exit(1); 01834 } 01835 LogInfo(COMPONENT_INIT, 01836 "NFSv4 ACL cache successfully initialized"); 01837 #endif /* _USE_NFS4_ACL */ 01838 01839 #ifdef _USE_9P 01840 LogDebug(COMPONENT_INIT, "Now building 9P resources"); 01841 if( _9p_init( &nfs_param._9p_param ) ) 01842 { 01843 LogCrit(COMPONENT_INIT, 01844 "Error while initializing 9P Resources"); 01845 exit(1); 01846 } 01847 LogInfo(COMPONENT_INIT, 01848 "9P resources successfully initialized"); 01849 #endif /* _USE_9P */ 01850 01851 /* Create the root entries for each exported FS */ 01852 if((rc = nfs_export_create_root_entry(nfs_param.pexportlist)) != TRUE) 01853 { 01854 LogFatal(COMPONENT_INIT, 01855 "Error initializing Cache Inode root entries"); 01856 } 01857 01858 /* Creation of FSAL_UP threads */ 01859 /* This thread depends on ALL parts of Ganesha being initialized. 01860 * So initialize Callback interface after everything else. */ 01861 #ifdef _USE_FSAL_UP 01862 nfs_Init_FSAL_UP(); /* initalizes an event pool */ 01863 #endif /* _USE_FSAL_UP */ 01864 01865 /* Create stable storage directory, this should not be necessary */ 01866 nfs4_create_recov_dir(); 01867 01868 /* initialize grace and read in the client IDs */ 01869 nfs4_init_grace(); 01870 nfs4_load_recov_clids(0); 01871 01872 /* Start grace period */ 01873 nfs4_start_grace(NULL); 01874 01875 LogInfo(COMPONENT_INIT, 01876 "Cache Inode root entries successfully created"); 01877 01878 /* Set accesscheck_support value to FSAL context object. */ 01879 #ifdef _USE_NFS4_ACL 01880 if (nfs_param.pexportlist) 01881 { 01882 nfs_param.pexportlist->FS_export_context 01883 .fe_static_fs_info->accesscheck_support 01884 = !cache_inode_params.use_test_access; 01885 LogDebug(COMPONENT_INIT, "accesscheck_support is set to %d", 01886 nfs_param.pexportlist->FS_export_context.fe_static_fs_info->accesscheck_support); 01887 } 01888 #endif 01889 01890 /* callback dispatch */ 01891 nfs_rpc_cb_pkginit(); 01892 #ifdef _USE_CB_SIMULATOR 01893 nfs_rpc_cbsim_pkginit(); 01894 #endif /* _USE_CB_SIMULATOR */ 01895 01896 } /* nfs_Init */ 01897 01902 void nfs_start(nfs_start_info_t * p_start_info) 01903 { 01904 struct rlimit ulimit_data; 01905 01906 #if 0 01907 /* Will remain as long as all FSAL are not yet in new format */ 01908 printf("---> fsal_handle_t:%lu\n", sizeof(cephfsal_handle_t)); 01909 printf("---> fsal_op_context_t:%lu\n", sizeof(cephfsal_op_context_t)); 01910 printf("---> fsal_file_t:%lu\n", sizeof(cephfsal_file_t)); 01911 printf("---> fsal_dir_t:%lu\n", sizeof(cephfsal_dir_t)); 01912 printf("---> fsal_export_context_t:%lu\n", sizeof(cephfsal_export_context_t)); 01913 printf("---> fsal_cookie_t:%lu\n", sizeof(cephfsal_cookie_t)); 01914 printf("---> fs_specific_initinfo_t:%lu\n", sizeof(cephfs_specific_initinfo_t)); 01915 #endif 01916 #if 0 01917 /* Will remain as long as all FSAL are not yet in new format */ 01918 printf("---> fsal_handle_t:%lu\n", sizeof(vfsfsal_handle_t)); 01919 printf("---> fsal_op_context_t:%lu\n", sizeof(vfsfsal_op_context_t)); 01920 printf("---> fsal_file_t:%lu\n", sizeof(vfsfsal_file_t)); 01921 printf("---> fsal_dir_t:%lu\n", sizeof(vfsfsal_dir_t)); 01922 printf("---> fsal_export_context_t:%lu\n", sizeof(vfsfsal_export_context_t)); 01923 printf("---> fsal_cookie_t:%lu\n", sizeof(vfsfsal_cookie_t)); 01924 printf("---> fs_specific_initinfo_t:%lu\n", sizeof(vfsfs_specific_initinfo_t)); 01925 #endif 01926 #if 0 01927 /* Will remain as long as all FSAL are not yet in new format */ 01928 printf("---> fsal_handle_t:%lu\n", sizeof(proxyfsal_handle_t)); 01929 printf("---> fsal_op_context_t:%lu\n", sizeof(proxyfsal_op_context_t)); 01930 printf("---> fsal_file_t:%lu\n", sizeof(proxyfsal_file_t)); 01931 printf("---> fsal_dir_t:%lu\n", sizeof(proxyfsal_dir_t)); 01932 printf("---> fsal_export_context_t:%lu\n", sizeof(proxyfsal_export_context_t)); 01933 printf("---> fsal_cookie_t:%lu\n", sizeof(proxyfsal_cookie_t)); 01934 printf("---> fs_specific_initinfo_t:%lu\n", sizeof(proxyfs_specific_initinfo_t)); 01935 #endif 01936 #if 0 01937 /* Will remain as long as all FSAL are not yet in new format */ 01938 printf("---> fsal_handle_t:%lu\n", sizeof(xfsfsal_handle_t)); 01939 printf("---> fsal_op_context_t:%lu\n", sizeof(xfsfsal_op_context_t)); 01940 printf("---> fsal_file_t:%lu\n", sizeof(xfsfsal_file_t)); 01941 printf("---> fsal_dir_t:%lu\n", sizeof(xfsfsal_dir_t)); 01942 printf("---> fsal_export_context_t:%lu\n", sizeof(xfsfsal_export_context_t)); 01943 printf("---> fsal_cookie_t:%lu\n", sizeof(xfsfsal_cookie_t)); 01944 printf("---> fs_specific_initinfo_t:%lu\n", sizeof(xfsfs_specific_initinfo_t)); 01945 #endif 01946 #if 0 01947 /* Will remain as long as all FSAL are not yet in new format */ 01948 printf("---> fsal_handle_t:%lu\n", sizeof(zfsfsal_handle_t)); 01949 printf("---> fsal_op_context_t:%lu\n", sizeof(zfsfsal_op_context_t)); 01950 printf("---> fsal_file_t:%lu\n", sizeof(zfsfsal_file_t)); 01951 printf("---> fsal_dir_t:%lu\n", sizeof(zfsfsal_dir_t)); 01952 printf("---> fsal_export_context_t:%lu\n", sizeof(zfsfsal_export_context_t)); 01953 printf("---> fsal_cookie_t:%lu\n", sizeof(zfsfsal_cookie_t)); 01954 printf("---> fs_specific_initinfo_t:%lu\n", sizeof(zfsfs_specific_initinfo_t)); 01955 #endif 01956 #if 0 01957 /* Will remain as long as all FSAL are not yet in new format */ 01958 printf("---> fsal_handle_t:%lu\n", sizeof(lustrefsal_handle_t)); 01959 printf("---> fsal_op_context_t:%lu\n", sizeof(lustrefsal_op_context_t)); 01960 printf("---> fsal_file_t:%lu\n", sizeof(lustrefsal_file_t)); 01961 printf("---> fsal_dir_t:%lu\n", sizeof(lustrefsal_dir_t)); 01962 printf("---> fsal_export_context_t:%lu\n", sizeof(lustrefsal_export_context_t)); 01963 printf("---> fsal_cookie_t:%lu\n", sizeof(lustrefsal_cookie_t)); 01964 printf("---> fs_specific_initinfo_t:%lu\n", sizeof(lustrefs_specific_initinfo_t)); 01965 printf("---> fsal_cred_t:%lu\n", sizeof(lustrefsal_cred_t)); 01966 #endif 01967 #if 0 01968 /* Will remain as long as all FSAL are not yet in new format */ 01969 printf("---> fsal_handle_t:%lu\n", sizeof(hpssfsal_handle_t)); 01970 printf("---> fsal_op_context_t:%lu\n", sizeof(hpssfsal_op_context_t)); 01971 printf("---> fsal_file_t:%lu\n", sizeof(hpssfsal_file_t)); 01972 printf("---> fsal_dir_t:%lu\n", sizeof(hpssfsal_dir_t)); 01973 printf("---> fsal_export_context_t:%lu\n", sizeof(hpssfsal_export_context_t)); 01974 printf("---> fsal_cookie_t:%lu\n", sizeof(hpssfsal_cookie_t)); 01975 printf("---> fs_specific_initinfo_t:%lu\n", sizeof(hpssfs_specific_initinfo_t)); 01976 printf("---> fsal_cred_t:%lu\n", sizeof(hpssfsal_cred_t)); 01977 #endif 01978 #if 0 01979 /* Will remain as long as all FSAL are not yet in new format */ 01980 printf("---> fsal_handle_t:%lu\n", sizeof(snmpfsal_handle_t)); 01981 printf("---> fsal_op_context_t:%lu\n", sizeof(snmpfsal_op_context_t)); 01982 printf("---> fsal_file_t:%lu\n", sizeof(snmpfsal_file_t)); 01983 printf("---> fsal_dir_t:%lu\n", sizeof(snmpfsal_dir_t)); 01984 printf("---> fsal_export_context_t:%lu\n", sizeof(snmpfsal_export_context_t)); 01985 printf("---> fsal_cookie_t:%lu\n", sizeof(snmpfsal_cookie_t)); 01986 printf("---> fs_specific_initinfo_t:%lu\n", sizeof(snmpfs_specific_initinfo_t)); 01987 #endif 01988 01989 /* store the start info so it is available for all layers */ 01990 nfs_start_info = *p_start_info; 01991 01992 if(p_start_info->dump_default_config == TRUE) 01993 { 01994 nfs_print_param_config(); 01995 exit(0); 01996 } 01997 01998 /* Set the Core dump size if set */ 01999 if(nfs_param.core_param.core_dump_size != -1) 02000 { 02001 LogDebug(COMPONENT_INIT, "I set the core size rlimit to %ld", 02002 nfs_param.core_param.core_dump_size); 02003 ulimit_data.rlim_cur = nfs_param.core_param.core_dump_size; 02004 ulimit_data.rlim_max = nfs_param.core_param.core_dump_size; 02005 02006 if(setrlimit(RLIMIT_CORE, &ulimit_data) != 0) 02007 { 02008 LogError(COMPONENT_INIT, ERR_SYS, ERR_SETRLIMIT, errno); 02009 LogCrit(COMPONENT_INIT, "Impossible to set RLIMIT_CORE to %ld", 02010 nfs_param.core_param.core_dump_size); 02011 } 02012 } 02013 02014 /* Print the worker parameters in log */ 02015 Print_param_worker_in_log(&(nfs_param.worker_param)); 02016 02017 { 02018 /* Set the write verifiers */ 02019 union 02020 { 02021 verifier4 NFS4_write_verifier; /* NFS V4 write verifier */ 02022 writeverf3 NFS3_write_verifier; /* NFS V3 write verifier */ 02023 uint64_t epoch; 02024 } build_verifier; 02025 02026 build_verifier.epoch = (uint64_t) ServerEpoch; 02027 02028 memcpy(NFS3_write_verifier, build_verifier.NFS3_write_verifier, sizeof(NFS3_write_verifier)); 02029 memcpy(NFS4_write_verifier, build_verifier.NFS4_write_verifier, sizeof(NFS4_write_verifier)); 02030 } 02031 /* Initialize all layers and service threads */ 02032 nfs_Init(p_start_info); 02033 02034 /* Spawns service threads */ 02035 nfs_Start_threads(); 02036 02037 #ifdef _USE_NLM 02038 /* NSM Unmonitor all */ 02039 nsm_unmonitor_all(); 02040 #endif 02041 02042 /* Populate the ID_MAPPER file with mapping file if needed */ 02043 if(nfs_param.uidmap_cache_param.mapfile[0] == '\0') 02044 { 02045 LogDebug(COMPONENT_INIT, "No Uid Map file is used"); 02046 } 02047 else 02048 { 02049 LogDebug(COMPONENT_INIT, "Populating UID_MAPPER with file %s", 02050 nfs_param.uidmap_cache_param.mapfile); 02051 if(idmap_populate(nfs_param.uidmap_cache_param.mapfile, UIDMAP_TYPE) != 02052 ID_MAPPER_SUCCESS) 02053 LogDebug(COMPONENT_INIT, "UID_MAPPER was NOT populated"); 02054 } 02055 02056 if(nfs_param.gidmap_cache_param.mapfile[0] == '\0') 02057 { 02058 LogDebug(COMPONENT_INIT, "No Gid Map file is used"); 02059 } 02060 else 02061 { 02062 LogDebug(COMPONENT_INIT, "Populating GID_MAPPER with file %s", 02063 nfs_param.uidmap_cache_param.mapfile); 02064 if(idmap_populate(nfs_param.gidmap_cache_param.mapfile, GIDMAP_TYPE) != 02065 ID_MAPPER_SUCCESS) 02066 LogDebug(COMPONENT_INIT, "GID_MAPPER was NOT populated"); 02067 } 02068 02069 if(nfs_param.ip_name_param.mapfile[0] == '\0') 02070 { 02071 LogDebug(COMPONENT_INIT, "No Hosts Map file is used"); 02072 } 02073 else 02074 { 02075 LogDebug(COMPONENT_INIT, "Populating IP_NAME with file %s", 02076 nfs_param.ip_name_param.mapfile); 02077 if(nfs_ip_name_populate(nfs_param.ip_name_param.mapfile) != IP_NAME_SUCCESS) 02078 LogDebug(COMPONENT_INIT, "IP_NAME was NOT populated"); 02079 } 02080 02081 /* Wait for the threads to complete their init step */ 02082 if(wait_for_threads_to_awaken() != PAUSE_OK) 02083 { 02084 /* Not quite sure what to do here... */ 02085 } 02086 else 02087 { 02088 LogEvent(COMPONENT_INIT, 02089 "-------------------------------------------------"); 02090 LogEvent(COMPONENT_INIT, 02091 " NFS SERVER INITIALIZED"); 02092 LogEvent(COMPONENT_INIT, 02093 "-------------------------------------------------"); 02094 } 02095 02096 /* Wait for dispatcher to exit */ 02097 LogDebug(COMPONENT_THREAD, 02098 "Wait for sigmgr thread to exit"); 02099 pthread_join(sigmgr_thrid, NULL); 02100 02101 /* Regular exit */ 02102 LogEvent(COMPONENT_MAIN, 02103 "NFS EXIT: regular exit"); 02104 02105 /* if not in grace period, clean up the old state directory */ 02106 if(!nfs_in_grace()) 02107 nfs4_clean_old_recov_dir(); 02108 02109 Cleanup(); 02110 02111 /* let main return 0 to exit */ 02112 } /* nfs_start */