nfs-ganesha 1.4
|
00001 /* 00002 * Copyright IBM Corporation, 2010 00003 * Contributor: M. Mohan Kumar <mohan@in.ibm.com> 00004 * 00005 * -------------------------- 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 3 of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 * 00021 * 00022 */ 00023 00024 #ifdef HAVE_CONFIG_H 00025 #include "config.h" 00026 #endif 00027 00028 #ifdef _SOLARIS 00029 #include "solaris_port.h" 00030 #endif 00031 00032 #include <stdio.h> 00033 #include <string.h> 00034 #include <pthread.h> 00035 #include "log.h" 00036 #include "ganesha_rpc.h" 00037 #include "nlm4.h" 00038 #include "sal_data.h" 00039 #include "cache_inode.h" 00040 #include "nlm_util.h" 00041 #include "nlm_async.h" 00042 00054 int nlm4_Granted_Res(nfs_arg_t *parg, 00055 exportlist_t *pexport, 00056 fsal_op_context_t *dummy_pcontext, 00057 nfs_worker_data_t *pworker, 00058 struct svc_req *preq, 00059 nfs_res_t *pres) 00060 { 00061 nlm4_res * arg = &parg->arg_nlm4_res; 00062 char buffer[1024]; 00063 state_status_t state_status = STATE_SUCCESS; 00064 state_cookie_entry_t * cookie_entry; 00065 fsal_op_context_t context, * pcontext = &context; 00066 00067 netobj_to_string(&arg->cookie, buffer, 1024); 00068 LogDebug(COMPONENT_NLM, 00069 "REQUEST PROCESSING: Calling nlm_Granted_Res cookie=%s", 00070 buffer); 00071 00072 if(state_find_grant(arg->cookie.n_bytes, 00073 arg->cookie.n_len, 00074 &cookie_entry, 00075 &state_status) != STATE_SUCCESS) 00076 { 00077 /* This must be an old NLM_GRANTED_RES */ 00078 LogFullDebug(COMPONENT_NLM, 00079 "Could not find cookie=%s (must be an old NLM_GRANTED_RES)", 00080 buffer); 00081 return NFS_REQ_OK; 00082 } 00083 00084 pthread_rwlock_wrlock(&cookie_entry->sce_pentry->state_lock); 00085 00086 if(cookie_entry->sce_lock_entry == NULL || 00087 cookie_entry->sce_lock_entry->sle_block_data == NULL || 00088 !nlm_block_data_to_fsal_context(cookie_entry->sce_lock_entry->sle_block_data, 00089 pcontext)) 00090 { 00091 /* This must be an old NLM_GRANTED_RES */ 00092 pthread_rwlock_unlock(&cookie_entry->sce_pentry->state_lock); 00093 LogFullDebug(COMPONENT_NLM, 00094 "Could not find block data for cookie=%s (must be an old NLM_GRANTED_RES)", 00095 buffer); 00096 return NFS_REQ_OK; 00097 } 00098 00099 pthread_rwlock_unlock(&cookie_entry->sce_pentry->state_lock); 00100 00101 if(arg->stat.stat != NLM4_GRANTED) 00102 { 00103 LogMajor(COMPONENT_NLM, 00104 "Granted call failed due to client error, releasing lock"); 00105 if(state_release_grant(pcontext, 00106 cookie_entry, 00107 &state_status) != STATE_SUCCESS) 00108 { 00109 LogDebug(COMPONENT_NLM, 00110 "cache_inode_release_grant failed"); 00111 } 00112 } 00113 else 00114 { 00115 state_complete_grant(pcontext, cookie_entry); 00116 nlm_signal_async_resp(cookie_entry); 00117 } 00118 00119 return NFS_REQ_OK; 00120 } 00121 00131 void nlm4_Granted_Res_Free(nfs_res_t * pres) 00132 { 00133 return; 00134 }