nfs-ganesha 1.4

nfs4_cb_Compound.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  * Portions Copyright (C) 2012, The Linux Box Corporation
00009  * Contributor : Matt Benjamin <matt@linuxbox.com>
00010  *
00011  * This program is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU Lesser General Public
00013  * License as published by the Free Software Foundation; either
00014  * version 3 of the License, or (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with this library; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00024  * 
00025  * ---------------------------------------
00026  */
00027 
00038 #ifdef HAVE_CONFIG_H
00039 #include "config.h"
00040 #endif
00041 
00042 #ifdef _SOLARIS
00043 #include "solaris_port.h"
00044 #endif
00045 
00046 #include <stdio.h>
00047 #include <string.h>
00048 #include <pthread.h>
00049 #include <fcntl.h>
00050 #include <sys/file.h>           /* for having FNDELAY */
00051 #include "HashData.h"
00052 #include "HashTable.h"
00053 #include "log.h"
00054 #include "ganesha_rpc.h"
00055 #include "nfs23.h"
00056 #include "nfs4.h"
00057 #include "mount.h"
00058 #include "nfs_core.h"
00059 #include "cache_inode.h"
00060 #include "nfs_exports.h"
00061 #include "nfs_creds.h"
00062 #include "nfs_proto_functions.h"
00063 #include "nfs_rpc_callback.h"
00064 
00065 static const nfs4_cb_tag_t cbtagtab4[] = {
00066     {NFS4_CB_TAG_DEFAULT, "Ganesha CB Compound", 19},
00067 };
00068 
00069 /* Some CITI-inspired compound helper ideas */
00070 
00071 void
00072 cb_compound_init_v4(nfs4_compound_t *cbt, uint32_t n_ops, uint32_t ident,
00073                     char *tag, uint32_t tag_len)
00074 {
00075     /* args */
00076     memset(cbt, 0, sizeof(nfs4_compound_t)); /* XDRS */
00077 
00078     cbt->v_u.v4.args.minorversion = 0;
00079     cbt->v_u.v4.args.callback_ident = ident;
00080     cbt->v_u.v4.args.argarray.argarray_val = alloc_cb_argop(n_ops);
00081     cbt->v_u.v4.args.argarray.argarray_len = 0; /* not n_ops, see below */
00082 
00083     if (tag) {
00084         /* sender must ensure tag is safe to queue */
00085         cbt->v_u.v4.args.tag.utf8string_val = tag;
00086         cbt->v_u.v4.args.tag.utf8string_len = tag_len;
00087     } else {
00088         cbt->v_u.v4.args.tag.utf8string_val =
00089             cbtagtab4[NFS4_CB_TAG_DEFAULT].val;
00090         cbt->v_u.v4.args.tag.utf8string_len =
00091             cbtagtab4[NFS4_CB_TAG_DEFAULT].len;
00092     }
00093 
00094     cbt->v_u.v4.res.resarray.resarray_val = alloc_cb_resop(n_ops);
00095     cbt->v_u.v4.res.resarray.resarray_len = 0;
00096 
00097 } /* cb_compound_init */
00098 
00099 void
00100 cb_compound_add_op(nfs4_compound_t *cbt, nfs_cb_argop4 *src)
00101 {
00102     uint32_t ix = /* old value */
00103         (cbt->v_u.v4.args.argarray.argarray_len)++;
00104     nfs_cb_argop4 *dst =
00105         cbt->v_u.v4.args.argarray.argarray_val + ix;
00106     *dst = *src;
00107     /* nothing to do for (zero) val region */
00108     cbt->v_u.v4.res.resarray.resarray_len++;
00109 }
00110 
00111 void
00112 cb_compound_free(nfs4_compound_t *cbt)
00113 {
00114     switch (cbt->v_u.v4.args.minorversion) {
00115     case 0:
00116         free_cb_argop(cbt->v_u.v4.args.argarray.argarray_val);
00117         free_cb_resop(cbt->v_u.v4.res.resarray.resarray_val);
00118         break;
00119     default:
00120         break;
00121     }
00122 }