nfs-ganesha 1.4

nfs4_op_renew.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 
00036 #ifdef HAVE_CONFIG_H
00037 #include "config.h"
00038 #endif
00039 
00040 #ifdef _SOLARIS
00041 #include "solaris_port.h"
00042 #endif
00043 
00044 #include <stdio.h>
00045 #include <string.h>
00046 #include <pthread.h>
00047 #include <fcntl.h>
00048 #include <sys/file.h>           /* for having FNDELAY */
00049 #include "HashData.h"
00050 #include "HashTable.h"
00051 #include "log.h"
00052 #include "ganesha_rpc.h"
00053 #include "nfs4.h"
00054 #include "sal_functions.h"
00055 #include "nfs_proto_functions.h"
00056 #include "nfs_core.h"
00057 
00075 #define arg_RENEW4 op->nfs_argop4_u.oprenew
00076 #define res_RENEW4 resp->nfs_resop4_u.oprenew
00077 
00078 int nfs4_op_renew(struct nfs_argop4 *op, compound_data_t * data, struct nfs_resop4 *resp)
00079 {
00080   nfs_client_id_t *pclientid;
00081 
00082   /* Lock are not supported */
00083   memset(resp, 0, sizeof(struct nfs_resop4));
00084   resp->resop = NFS4_OP_RENEW;
00085 
00086   /* Tell the admin what I am doing... */
00087   LogFullDebug(COMPONENT_CLIENTID, "RENEW Client id = %"PRIx64, arg_RENEW4.clientid);
00088 
00089   /* Is this an existing client id ? */
00090   if(nfs_client_id_get_confirmed(arg_RENEW4.clientid, &pclientid) !=
00091       CLIENT_ID_SUCCESS)
00092     {
00093       /* Unknown client id */
00094       res_RENEW4.status = NFS4ERR_STALE_CLIENTID;
00095       return res_RENEW4.status;
00096     }
00097 
00098   P(pclientid->cid_mutex);
00099 
00100   if(!reserve_lease(pclientid))
00101     {
00102       res_RENEW4.status = NFS4ERR_EXPIRED;
00103     }
00104   else
00105     {
00106       update_lease(pclientid);
00107       res_RENEW4.status = NFS4_OK;      /* Regular exit */
00108     }
00109 
00110   V(pclientid->cid_mutex);
00111 
00112   dec_client_id_ref(pclientid);
00113 
00114   return res_RENEW4.status;
00115 }                               /* nfs4_op_renew */
00116 
00127 void nfs4_op_renew_Free(RENEW4res * resp)
00128 {
00129   /* Nothing to be done */
00130   return;
00131 }                               /* nfs4_op_renew_Free */