nfs-ganesha 1.4
|
00001 /* 00002 * This program is free software; you can redistribute it and/or 00003 * modify it under the terms of the GNU Lesser General Public 00004 * License as published by the Free Software Foundation; either 00005 * version 3 of the License, or (at your option) any later version. 00006 * 00007 * This program is distributed in the hope that it will be useful, 00008 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00010 * Lesser General Public License for more details. 00011 * 00012 * You should have received a copy of the GNU Lesser General Public 00013 * License along with this library; if not, write to the Free Software 00014 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00015 * 00016 * --------------------------------------- 00017 */ 00018 00023 #ifdef HAVE_CONFIG_H 00024 #include "config.h" 00025 #endif 00026 00027 #ifdef _SOLARIS 00028 #include "solaris_port.h" 00029 #endif 00030 00031 #include <stdio.h> 00032 #include <string.h> 00033 #include <pthread.h> 00034 00035 #include "nfs_core.h" 00036 #include "log.h" 00037 #include "fsal.h" 00038 #include "cache_inode.h" 00039 #include "HashTable.h" 00040 #include "fsal_up.h" 00041 #include "sal_functions.h" 00042 00043 /* Set the FSAL UP functions that will be used to process events. 00044 * This is called DUMB_FSAL_UP because it only invalidates cache inode 00045 * entires ... inode entries are not updated or refreshed through this 00046 * interface. */ 00047 00048 fsal_status_t dumb_fsal_up_invalidate_step1(fsal_up_event_data_t * pevdata) 00049 { 00050 cache_inode_status_t cache_status; 00051 00052 LogDebug(COMPONENT_FSAL_UP, 00053 "FSAL_UP_DUMB: calling cache_inode_invalidate()"); 00054 00055 /* Lock the entry */ 00056 cache_inode_invalidate(&pevdata->event_context.fsal_data, 00057 &cache_status, 00058 CACHE_INODE_INVALIDATE_CLEARBITS); 00059 00060 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00061 } 00062 00063 fsal_status_t dumb_fsal_up_invalidate_step2(fsal_up_event_data_t * pevdata) 00064 { 00065 cache_inode_status_t cache_status; 00066 00067 LogDebug(COMPONENT_FSAL_UP, 00068 "FSAL_UP_DUMB: calling cache_inode_invalidate()"); 00069 00070 /* Lock the entry */ 00071 cache_inode_invalidate(&pevdata->event_context.fsal_data, 00072 &cache_status, 00073 CACHE_INODE_INVALIDATE_CLOSE); 00074 00075 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00076 } 00077 fsal_status_t dumb_fsal_up_update(fsal_up_event_data_t * pevdata) 00078 { 00079 cache_inode_status_t cache_status; 00080 00081 LogFullDebug(COMPONENT_FSAL_UP, 00082 "FSAL_UP_DUMB: Entered dumb_fsal_up_update\n"); 00083 if ((pevdata->type.update.upu_flags & FSAL_UP_NLINK) && 00084 (pevdata->type.update.upu_stat_buf.st_nlink == 0) ) 00085 { 00086 LogFullDebug(COMPONENT_FSAL_UP, 00087 "FSAL_UP_DUMB: nlink has become zero; close fds\n"); 00088 cache_inode_invalidate(&pevdata->event_context.fsal_data, 00089 &cache_status, 00090 (CACHE_INODE_INVALIDATE_CLEARBITS | 00091 CACHE_INODE_INVALIDATE_CLOSE)); 00092 } 00093 else 00094 cache_inode_invalidate(&pevdata->event_context.fsal_data, 00095 &cache_status, 00096 CACHE_INODE_INVALIDATE_CLEARBITS); 00097 00098 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00099 } 00100 00101 #define INVALIDATE_STUB { \ 00102 return dumb_fsal_up_invalidate_step1(pevdata); \ 00103 } while(0); 00104 00105 fsal_status_t dumb_fsal_up_create(fsal_up_event_data_t * pevdata) 00106 { 00107 INVALIDATE_STUB; 00108 } 00109 00110 fsal_status_t dumb_fsal_up_unlink(fsal_up_event_data_t * pevdata) 00111 { 00112 INVALIDATE_STUB; 00113 } 00114 00115 fsal_status_t dumb_fsal_up_rename(fsal_up_event_data_t * pevdata) 00116 { 00117 INVALIDATE_STUB; 00118 } 00119 00120 fsal_status_t dumb_fsal_up_commit(fsal_up_event_data_t * pevdata) 00121 { 00122 INVALIDATE_STUB; 00123 } 00124 00125 fsal_status_t dumb_fsal_up_write(fsal_up_event_data_t * pevdata) 00126 { 00127 INVALIDATE_STUB; 00128 } 00129 00130 fsal_status_t dumb_fsal_up_link(fsal_up_event_data_t * pevdata) 00131 { 00132 INVALIDATE_STUB; 00133 } 00134 00135 fsal_status_t dumb_fsal_up_lock_grant(fsal_up_event_data_t * pevdata) 00136 { 00137 #ifdef _USE_BLOCKING_LOCKS 00138 cache_inode_status_t cache_status; 00139 cache_entry_t * pentry = NULL; 00140 fsal_attrib_list_t attr; 00141 00142 LogDebug(COMPONENT_FSAL_UP, 00143 "FSAL_UP_DUMB: calling cache_inode_get()"); 00144 pentry = cache_inode_get(&pevdata->event_context.fsal_data, 00145 &attr, NULL, NULL, 00146 &cache_status); 00147 if(pentry == NULL) 00148 { 00149 LogDebug(COMPONENT_FSAL_UP, 00150 "FSAL_UP_DUMB: cache inode get failed."); 00151 /* Not an error. Expecting some nodes will not have it in cache in 00152 * a cluster. */ 00153 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00154 } 00155 00156 LogDebug(COMPONENT_FSAL_UP, 00157 "FSAL_UP_DUMB: Lock Grant found entry %p", 00158 pentry); 00159 00160 grant_blocked_lock_upcall(pentry, 00161 pevdata->type.lock_grant.lock_owner, 00162 &pevdata->type.lock_grant.lock_param); 00163 00164 00165 if(pentry) 00166 cache_inode_put(pentry); 00167 00168 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00169 #else 00170 INVALIDATE_STUB; 00171 #endif 00172 } 00173 00174 fsal_status_t dumb_fsal_up_lock_avail(fsal_up_event_data_t * pevdata) 00175 { 00176 #ifdef _USE_BLOCKING_LOCKS 00177 cache_inode_status_t cache_status; 00178 cache_entry_t * pentry = NULL; 00179 fsal_attrib_list_t attr; 00180 00181 LogDebug(COMPONENT_FSAL_UP, 00182 "FSAL_UP_DUMB: calling cache_inode_get()"); 00183 pentry = cache_inode_get(&pevdata->event_context.fsal_data, 00184 &attr, NULL, NULL, &cache_status); 00185 if(pentry == NULL) 00186 { 00187 LogDebug(COMPONENT_FSAL_UP, 00188 "FSAL_UP_DUMB: cache inode get failed."); 00189 /* Not an error. Expecting some nodes will not have it in cache in 00190 * a cluster. */ 00191 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00192 } 00193 00194 LogDebug(COMPONENT_FSAL_UP, 00195 "FSAL_UP_DUMB: Lock Available found entry %p", 00196 pentry); 00197 00198 available_blocked_lock_upcall(pentry, 00199 pevdata->type.lock_grant.lock_owner, 00200 &pevdata->type.lock_grant.lock_param); 00201 00202 if(pentry) 00203 cache_inode_put(pentry); 00204 00205 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00206 #else 00207 INVALIDATE_STUB; 00208 #endif 00209 } 00210 00211 fsal_status_t dumb_fsal_up_open(fsal_up_event_data_t * pevdata) 00212 { 00213 INVALIDATE_STUB; 00214 } 00215 00216 fsal_status_t dumb_fsal_up_close(fsal_up_event_data_t * pevdata) 00217 { 00218 INVALIDATE_STUB; 00219 } 00220 00221 fsal_status_t dumb_fsal_up_setattr(fsal_up_event_data_t * pevdata) 00222 { 00223 INVALIDATE_STUB; 00224 } 00225 00226 fsal_up_event_functions_t dumb_event_func = { 00227 .fsal_up_create = dumb_fsal_up_create, 00228 .fsal_up_unlink = dumb_fsal_up_unlink, 00229 .fsal_up_rename = dumb_fsal_up_rename, 00230 .fsal_up_commit = dumb_fsal_up_commit, 00231 .fsal_up_write = dumb_fsal_up_write, 00232 .fsal_up_link = dumb_fsal_up_link, 00233 .fsal_up_lock_grant = dumb_fsal_up_lock_grant, 00234 .fsal_up_lock_avail = dumb_fsal_up_lock_avail, 00235 .fsal_up_open = dumb_fsal_up_open, 00236 .fsal_up_close = dumb_fsal_up_close, 00237 .fsal_up_setattr = dumb_fsal_up_setattr, 00238 .fsal_up_update = dumb_fsal_up_update, 00239 .fsal_up_invalidate = dumb_fsal_up_invalidate_step1 00240 }; 00241 00242 fsal_up_event_functions_t *get_fsal_up_dumb_functions() 00243 { 00244 return &dumb_event_func; 00245 }