nfs-ganesha 1.4

cache_content_release_entry.c

Go to the documentation of this file.
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 
00037 #ifdef HAVE_CONFIG_H
00038 #include "config.h"
00039 #endif
00040 
00041 #ifdef _SOLARIS
00042 #include "solaris_port.h"
00043 #endif                          /* _SOLARIS */
00044 
00045 #include "LRU_List.h"
00046 #include "log.h"
00047 #include "HashData.h"
00048 #include "HashTable.h"
00049 #include "fsal.h"
00050 #include "cache_inode.h"
00051 #include "cache_content.h"
00052 
00053 #include <unistd.h>
00054 #include <sys/types.h>
00055 #include <sys/param.h>
00056 #include <time.h>
00057 #include <pthread.h>
00058 #include <errno.h>
00059 #include <fcntl.h>
00060 #include <string.h>
00061 
00078 cache_content_status_t cache_content_release_entry(cache_content_entry_t * pentry,
00079                                                    cache_content_client_t * pclient,
00080                                                    cache_content_status_t * pstatus)
00081 {
00082   /* By default, operation status is successful */
00083   *pstatus = CACHE_CONTENT_SUCCESS;
00084 
00085   /* stat */
00086   pclient->stat.func_stats.nb_call[CACHE_CONTENT_RELEASE_ENTRY] += 1;
00087 
00088   /* close the associated opened file */
00089   if(pentry->local_fs_entry.opened_file.local_fd > 0)
00090     {
00091       close(pentry->local_fs_entry.opened_file.local_fd);
00092       pentry->local_fs_entry.opened_file.last_op = 0;
00093     }
00094 
00095   /* Finally puts the entry back to entry pool for future use */
00096   pool_free(pclient->content_pool, pentry);
00097 
00098   /* Remove the index file */
00099   if(unlink(pentry->local_fs_entry.cache_path_index) != 0)
00100     {
00101       if(errno != ENOENT)
00102         LogEvent(COMPONENT_CACHE_CONTENT,
00103                           "cache_content_release_entry: error when unlinking index file %s, errno = ( %d, '%s' )",
00104                           pentry->local_fs_entry.cache_path_index,
00105                           errno, strerror(errno));
00106     }
00107 
00108   /* Remove the data file */
00109   if(unlink(pentry->local_fs_entry.cache_path_data) != 0)
00110     {
00111       if(errno != ENOENT)
00112         LogEvent(COMPONENT_CACHE_CONTENT,
00113                           "cache_content_release_entry: error when unlinking index file %s, errno = ( %d, '%s' )",
00114                           pentry->local_fs_entry.cache_path_data, errno, strerror(errno));
00115     }
00116 
00117   return *pstatus;
00118 }                               /* cache_content_release_entry */