nfs-ganesha 1.4
|
00001 /* 00002 * vim:expandtab:shiftwidth=8:tabstop=8: 00003 */ 00004 00009 #ifdef HAVE_CONFIG_H 00010 #include "config.h" 00011 #endif 00012 00013 #include <assert.h> 00014 00015 #include "fsal_common.h" 00016 #include "fsal_internal.h" 00017 00018 extern size_t i_snapshots; 00019 extern snapshot_t *p_snapshots; 00020 extern pthread_rwlock_t vfs_lock; 00021 00022 libzfswrap_vfs_t *ZFSFSAL_GetVFS(zfsfsal_handle_t *handle) 00023 { 00024 /* This function must be called with the reader lock locked */ 00025 assert(pthread_rwlock_trywrlock(&vfs_lock) != 0); 00026 /* Check for the zpool (index == 0) */ 00027 if(handle->data.i_snap == 0) 00028 return p_snapshots[0].p_vfs; 00029 00030 /* Handle the indirection */ 00031 int i; 00032 for(i = 1; i < i_snapshots + 1; i++) 00033 { 00034 if(p_snapshots[i].index == handle->data.i_snap) 00035 { 00036 LogFullDebug(COMPONENT_FSAL, "Looking up inside the snapshot n°%d", handle->data.i_snap); 00037 return p_snapshots[i].p_vfs; 00038 } 00039 } 00040 00041 LogMajor(COMPONENT_FSAL, "Unable to get the right VFS"); 00042 return NULL; 00043 } 00044 00045 void ZFSFSAL_VFS_RDLock() 00046 { 00047 pthread_rwlock_rdlock(&vfs_lock); 00048 } 00049 00050 void ZFSFSAL_VFS_WRLock() 00051 { 00052 pthread_rwlock_wrlock(&vfs_lock); 00053 } 00054 00055 void ZFSFSAL_VFS_Unlock() 00056 { 00057 pthread_rwlock_unlock(&vfs_lock); 00058 }