REBASEME:
missed the following change from:

>>>>>>> dd52d95... Corrected pseudo lookupp to set file type to DIRECTORY so readdir passes

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME:
Fixed

diff --git a/src/Cache_inode/cache_inode_get.c b/src/Cache_inode/cache_inode_get.c
index 4c4a9bf..888f9cf 100644
--- a/src/Cache_inode/cache_inode_get.c
+++ b/src/Cache_inode/cache_inode_get.c
@@ -142,7 +142,7 @@ cache_inode_get(cache_inode_fsal_data_t *fsdata,
      HashTable_ReleaseLatched(fh_to_cache_entry_ht, &latch);

      if (!context) {
-          /* Upcalls have no access to fsal_op_context_t,
+          /* Upcalls have no access to a cache_inode_client_t,
              so just return the entry without revalidating it or

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/Cache_inode/cache_inode_invalidate.c b/src/Cache_inode/cache_inode_invalidate.c
index 01bc357..d573302 100644
--- a/src/Cache_inode/cache_inode_invalidate.c
+++ b/src/Cache_inode/cache_inode_invalidate.c
@@ -143,6 +143,7 @@ cache_inode_invalidate(cache_inode_fsal_data_t *fsal_data,

      if (entry->type == REGULAR_FILE) {
           cache_inode_close(entry,
+                            NULL,
                             (CACHE_INODE_FLAG_REALLYCLOSE |
                              CACHE_INODE_FLAG_CONTENT_HAVE |
                              CACHE_INODE_FLAG_CONTENT_HOLD),

Looks like this was removing a client pointer, not sure where we should have done it

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/Cache_inode/cache_inode_misc.c b/src/Cache_inode/cache_inode_misc.c
index 78f0253..f4506c5 100644
--- a/src/Cache_inode/cache_inode_misc.c
+++ b/src/Cache_inode/cache_inode_misc.c
@@ -148,8 +148,6 @@ const char *cache_inode_err_str(cache_inode_status_t err)
         return "CACHE_INODE_FILE_BIG";
       case CACHE_INODE_KILLED:
         return "CACHE_INODE_KILLED";
-      case CACHE_INODE_FILE_OPEN:
-        return "CACHE_INODE_FILE_OPEN";
     }
   return "unknown";
 }

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/Cache_inode/cache_inode_statfs.c b/src/Cache_inode/cache_inode_statfs.c
index e574778..f93c48e 100644
--- a/src/Cache_inode/cache_inode_statfs.c
+++ b/src/Cache_inode/cache_inode_statfs.c
@@ -86,9 +86,14 @@ cache_inode_status_t cache_inode_statfs(cache_entry_t *entry,
                                          dynamicinfo))))
     {
       *status = cache_inode_error_convert(fsal_status);
+/**
+ * @todo ACE: Re-enable this after we kill cache_inode_client_t
+ */
+#if 0
       if (fsal_status.major == ERR_FSAL_STALE) {
-           cache_inode_kill_entry(entry);
+           cache_inode_kill_entry(entry, client);
       }
+#endif /* 0 */
       return *status;
     }
   LogFullDebug(COMPONENT_CACHE_INODE,

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/FSAL_UP/DUMB/fsal_up_functions.c b/src/FSAL_UP/DUMB/fsal_up_functions.c
index e1def25..2014803 100644
--- a/src/FSAL_UP/DUMB/fsal_up_functions.c
+++ b/src/FSAL_UP/DUMB/fsal_up_functions.c
@@ -72,7 +72,7 @@ fsal_status_t dumb_fsal_up_update(fsal_up_event_data_t * pevdata)
     {
       pentry = cache_inode_get(&pevdata->event_context.fsal_data,
                                &attr, NULL, NULL,
-                               &cache_status);
+                               NULL, &cache_status);
       if(pentry == NULL)
         {
           LogDebug(COMPONENT_FSAL_UP,
@@ -84,13 +84,13 @@ fsal_status_t dumb_fsal_up_update(fsal_up_event_data_t * pevdata)

       LogFullDebug(COMPONENT_FSAL_UP,
                "FSAL_UP_DUMB: nlink has become zero; close fds\n");
-      cache_inode_close(pentry, CACHE_INODE_FLAG_REALLYCLOSE, &cache_status);
+      cache_inode_close(pentry, NULL, CACHE_INODE_FLAG_REALLYCLOSE, &cache_status);
     }

   cache_inode_invalidate(&pevdata->event_context.fsal_data, &cache_status);

   if(pentry)
-    cache_inode_put(pentry);
+    cache_inode_put(pentry, NULL);
   ReturnCode(ERR_FSAL_NO_ERROR, 0);
 }

cache inode client pointers

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/FSAL_UP/fsal_up_thread.c b/src/FSAL_UP/fsal_up_thread.c
index dc51059..74e9df9 100644
--- a/src/FSAL_UP/fsal_up_thread.c
+++ b/src/FSAL_UP/fsal_up_thread.c
@@ -72,6 +72,21 @@ void *fsal_up_process_thread(void *UnUsedArg)

   SetNameFunction("fsal_up_process_thread");

+#ifndef _NO_BUDDY_SYSTEM
+  {
+    int rc;
+
+    if((rc = BuddyInit(&nfs_param.buddy_param_fsal_up_process)) != BUDDY_SUCCESS)
+      {
+        /* Failed init */
+        LogFatal(COMPONENT_FSAL_UP,
+                 "fsal_up_process_thread: MemoryManager couldn't be initialized");
+      }
+    LogInfo(COMPONENT_FSAL_UP,
+            "fsal_up_process_thread: MemoryManager successfully initialized");
+  }
+#endif
+
   init_glist(&fsal_up_process_queue);
   tcb_new(&fsal_up_process_tcb, "FSAL_UP Process Thread");

@@ -143,9 +158,9 @@ void *fsal_up_process_thread(void *UnUsedArg)
             /* Release the mutex */
             V(fsal_up_process_tcb.tcb_mutex);
             fupevent->event_process_func(&fupevent->event_data);
-            gsh_free(fupevent->event_data.event_context.fsal_data.fh_desc.start);
+            Mem_Free(fupevent->event_data.event_context.fsal_data.fh_desc.start);
             pthread_mutex_lock(&nfs_param.fsal_up_param.event_pool_lock);
-            pool_free(nfs_param.fsal_up_param.event_pool, fupevent);
+            ReleaseToPool(fupevent, &nfs_param.fsal_up_param.event_pool);
             pthread_mutex_unlock(&nfs_param.fsal_up_param.event_pool_lock);

             continue;
@@ -331,10 +346,10 @@ fsal_status_t process_event(fsal_up_event_t *myevent, fsal_up_event_functions_t
     default:
       LogDebug(COMPONENT_FSAL_UP, "Unknown FSAL UP event type found: %d",
               myevent->event_type);
-      gsh_free(myevent->event_data.event_context.fsal_data.fh_desc.start);
+      Mem_Free(myevent->event_data.event_context.fsal_data.fh_desc.start);

       pthread_mutex_lock(&nfs_param.fsal_up_param.event_pool_lock);
-      pool_free(nfs_param.fsal_up_param.event_pool, myevent);
+      ReleaseToPool(myevent, &nfs_param.fsal_up_param.event_pool);
       pthread_mutex_unlock(&nfs_param.fsal_up_param.event_pool_lock);

       ReturnCode(ERR_FSAL_NO_ERROR, 0);
@@ -542,6 +557,12 @@ void *fsal_up_thread(void *Arg)
                        fsal_up_args->export_entry->filesystem_id.minor,
                        fsal_up_args->export_entry->id);
             }
+          tmpevent = event;
+          gsh_free(tmpevent->event_data.event_context.fsal_data.fh_desc.start);
+          pthread_mutex_lock(fsal_up_context.event_pool_lock);
+          pool_free(nfs_param.fsal_up_param.event_pool, tmpevent);
+          pthread_mutex_unlock(fsal_up_context.event_pool_lock);
+          event_nb--;
         }

       LogDebug(COMPONENT_FSAL_UP, "%lu events not found for filesystem"

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix
diff --git a/src/MainNFSD/nfs_init.c b/src/MainNFSD/nfs_init.c
index cf86967..9fbc292 100644
--- a/src/MainNFSD/nfs_init.c
+++ b/src/MainNFSD/nfs_init.c
@@ -471,6 +471,7 @@ void nfs_set_param_default()
   /*  Worker parameters : NFSv4 Unconfirmed Client id table */
   nfs_param.client_id_param.cid_unconfirmed_hash_param.index_size = PRIME_CLIENT_ID;
   nfs_param.client_id_param.cid_unconfirmed_hash_param.alphabet_length = 10; /* ipaddr is a numerical decimal value */
+  nfs_param.client_id_param.cid_unconfirmed_hash_param.nb_node_prealloc = NB_PREALLOC_HASH_CLIENT_ID;
   nfs_param.client_id_param.cid_unconfirmed_hash_param.hash_func_key = client_id_value_hash_func;
   nfs_param.client_id_param.cid_unconfirmed_hash_param.hash_func_rbt = client_id_rbt_hash_func;
   nfs_param.client_id_param.cid_unconfirmed_hash_param.hash_func_both = NULL ;
@@ -484,6 +485,7 @@ void nfs_set_param_default()
   /*  Worker parameters : NFSv4 Confirmed Client id table */
   nfs_param.client_id_param.cid_confirmed_hash_param.index_size = PRIME_CLIENT_ID;
   nfs_param.client_id_param.cid_confirmed_hash_param.alphabet_length = 10; /* ipaddr is a numerical decimal value */
+  nfs_param.client_id_param.cid_confirmed_hash_param.nb_node_prealloc = NB_PREALLOC_HASH_CLIENT_ID;
   nfs_param.client_id_param.cid_confirmed_hash_param.hash_func_key = client_id_value_hash_func;
   nfs_param.client_id_param.cid_confirmed_hash_param.hash_func_rbt = client_id_rbt_hash_func;
   nfs_param.client_id_param.cid_confirmed_hash_param.hash_func_both = NULL ;
@@ -497,6 +499,7 @@ void nfs_set_param_default()
   /*  Worker parameters : NFSv4 Client Record table */
   nfs_param.client_id_param.cr_hash_param.index_size = PRIME_CLIENT_ID;
   nfs_param.client_id_param.cr_hash_param.alphabet_length = 10; /* ipaddr is a numerical decimal value */
+  nfs_param.client_id_param.cr_hash_param.nb_node_prealloc = NB_PREALLOC_HASH_CLIENT_ID;
   nfs_param.client_id_param.cr_hash_param.hash_func_key = client_record_value_hash_func;
   nfs_param.client_id_param.cr_hash_param.hash_func_rbt = client_record_rbt_hash_func;
   nfs_param.client_id_param.cr_hash_param.hash_func_both = NULL ;
@@ -598,8 +601,9 @@ void nfs_set_param_default()
   cache_inode_params.hparam.compare_key = cache_inode_compare_key_fsal;
   cache_inode_params.hparam.key_to_str = display_cache;
   cache_inode_params.hparam.val_to_str = display_cache;
+  cache_inode_params.hparam.name = "Cache Inode";
   cache_inode_params.hparam.flags = HT_FLAG_CACHE;
-  cache_inode_params.hparam.ht_log_component = COMPONENT_CACHE_INODE;
+  cache_inode_params.hparam.hparam.ht_log_component = COMPONENT_CACHE_INODE;

 #ifdef _USE_NLM
   /* Cache inode parameters : cookie hash table */
@@ -610,6 +614,7 @@ void nfs_set_param_default()
   cache_inode_params.cookie_param.compare_key = compare_lock_cookie_key;
   cache_inode_params.cookie_param.key_to_str = display_lock_cookie_key;
   cache_inode_params.cookie_param.val_to_str = display_lock_cookie_val;
+  cache_inode_params.cookie_param.name = "Lock Cookie";
   cache_inode_params.cookie_param.flags = HT_FLAG_NONE;
   cache_inode_params.cookie_param.ht_log_component = COMPONENT_STATE;
 #endif
@@ -1515,7 +1520,7 @@ static void nfs_Init(const nfs_start_info_t * p_start_info)
                            NULL,
                            constructor_request_data_t,
                            NULL);
-  if(!request_pool)
+  if(!(request_pool))
     {
       LogCrit(COMPONENT_INIT,
               "Error while allocating request pool");
@@ -1523,20 +1528,6 @@ static void nfs_Init(const nfs_start_info_t * p_start_info)
       Fatal();
     }

-  request_data_pool = pool_init("Request Data Pool",
-                                sizeof(nfs_request_data_t),
-                                pool_basic_substrate,
-                                NULL,
-                                constructor_nfs_request_data_t,
-                                NULL);
-  if(!request_data_pool)
-    {
-      LogCrit(COMPONENT_INIT,
-              "Error while allocating request data pool");
-      LogError(COMPONENT_INIT, ERR_SYS, ERR_MALLOC, errno);
-      Fatal();
-    }
-
   dupreq_pool = pool_init("Duplicate Request Pool",
                           sizeof(dupreq_entry_t),
                           pool_basic_substrate,
@@ -1665,6 +1656,7 @@ static void nfs_Init(const nfs_start_info_t * p_start_info)
                  "Error while initializing worker data #%d", i);

       sprintf(name, "IP Stats for worker %d", i);
+      nfs_param.ip_stats_param.hash_param.name = gsh_strdup(name);
       ht_ip_stats[i] = nfs_Init_ip_stats(nfs_param.ip_stats_param);

       if(ht_ip_stats[i] == NULL)
@@ -1853,9 +1845,7 @@ static void nfs_Init(const nfs_start_info_t * p_start_info)
 #ifdef _USE_NFS4_ACL
   if (nfs_param.pexportlist)
     {
-      nfs_param.pexportlist->FS_export_context
-           .fe_static_fs_info->accesscheck_support
-           = !cache_inode_params.use_test_access;
+      nfs_param.pexportlist->FS_export_context.fe_static_fs_info->accesscheck_support = !nfs_param.cache_layers_param.cache_inode_client_param.use_test_access;
       LogDebug(COMPONENT_INIT, "accesscheck_support is set to %d",
            nfs_param.pexportlist->FS_export_context.fe_static_fs_info->accesscheck_support);
     }

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/MainNFSD/nfs_reaper_thread.c b/src/MainNFSD/nfs_reaper_thread.c
index a557cc1..ed4caea 100644
--- a/src/MainNFSD/nfs_reaper_thread.c
+++ b/src/MainNFSD/nfs_reaper_thread.c
@@ -129,6 +129,17 @@ void *reaper_thread(void *UnusedArg)

   SetNameFunction("reaper_thr");

+#ifndef _NO_BUDDY_SYSTEM
+  if(BuddyInit(&nfs_param.buddy_param_admin) != BUDDY_SUCCESS)
+    {
+      /* Failed init */
+      LogFatal(COMPONENT_CLIENTID,
+               "Memory manager could not be initialized for reaper thread");
+    }
+  LogInfo(COMPONENT_CLIENTID,
+          "Memory manager successfully initialized for reaper thread");
+#endif
+
   if(nfs_param.nfsv4_param.lease_lifetime < (2 * REAPER_DELAY))
     reaper_delay = nfs_param.nfsv4_param.lease_lifetime / 2;

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/MainNFSD/nfs_rpc_callback_simulator.c b/src/MainNFSD/nfs_rpc_callback_simulator.c
index bfd2f86..5d3e46b 100644
--- a/src/MainNFSD/nfs_rpc_callback_simulator.c
+++ b/src/MainNFSD/nfs_rpc_callback_simulator.c
@@ -40,6 +40,7 @@
 #include <time.h>
 #include <pthread.h>
 #include <assert.h>
+#include "stuff_alloc.h"
 #include "nlm_list.h"
 #include "abstract_mem.h"
 #include "fsal.h"
@@ -203,11 +204,11 @@ static void cbsim_free_compound(nfs4_compound_t *cbt)
         if (argop) {
             switch (argop->argop) {
             case  NFS4_OP_CB_RECALL:
-                gsh_free(argop->nfs_cb_argop4_u.opcbrecall.fh.nfs_fh4_val);
+                Mem_Free(argop->nfs_cb_argop4_u.opcbrecall.fh.nfs_fh4_val);
                 break;
             default:
                 /* TODO:  ahem */
-                break;
+                break;
             }
         }
     }

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/MainNFSD/nfs_rpc_dispatcher_thread.c b/src/MainNFSD/nfs_rpc_dispatcher_thread.c
index 23dad4e..7d82c8f 100644
--- a/src/MainNFSD/nfs_rpc_dispatcher_thread.c
+++ b/src/MainNFSD/nfs_rpc_dispatcher_thread.c
@@ -30,8 +30,8 @@
  * \version $Revision: 1.96 $
  * \brief   The file that contain the 'rpc_dispatcher_thread' routine for the nfsd.
  *
- * nfs_rpc_dispatcher.c : The file that contain the 'rpc_dispatcher_thread' routine for the nfsd (and all
- * the related stuff).
+ * nfs_rpc_dispatcher.c : The file that contain the 'rpc_dispatcher_thread' routine
+ * for the nfsd (and all the related stuff).
  *
  */
 #ifdef HAVE_CONFIG_H
@@ -99,7 +99,7 @@ static struct rpc_evchan rpc_evchan[N_EVENT_CHAN];
 static u_int nfs_rpc_rdvs(SVCXPRT *xprt, SVCXPRT *newxprt, const u_int flags,
                           void *u_data);
 static bool_t nfs_rpc_getreq_ng(SVCXPRT *xprt /*, int chan_id */);
-static void nfs_rpc_free_xprt(SVCXPRT *xprt);
+static bool_t nfs_rpc_free_xprt(SVCXPRT *xprt);

 /**
  *
@@ -743,7 +743,7 @@ static u_int nfs_rpc_rdvs(SVCXPRT *xprt, SVCXPRT *newxprt, const u_int flags,
     return (0);
 }

-static void nfs_rpc_free_xprt(SVCXPRT *xprt)
+static bool_t nfs_rpc_free_xprt(SVCXPRT *xprt)
 {
     if (xprt->xp_u1)
         free_gsh_xprt_private(xprt->xp_u1);
@@ -754,7 +754,7 @@ static void nfs_rpc_free_xprt(SVCXPRT *xprt)
  * whome the worker is ready and is not garbagging.
  */

-/* PhD: Please note that I renamed this function, added
+/* PhD: Please note that I renamed this function, added
  * it prototype to include/nfs_core.h and removed its "static" tag.
  * This is done to share this code with the 9P implementation */

@@ -875,26 +875,26 @@ nfs_core_select_worker_queue(unsigned int avoid_index)
 request_data_t *
 nfs_rpc_get_nfsreq(nfs_worker_data_t *worker, uint32_t flags)
 {
-    request_data_t *nfsreq = NULL;
+    request_data_t *pnfsreq = NULL;

-    nfsreq = pool_alloc(request_pool, NULL);
+    pnfsreq = pool_alloc(request_pool, NULL);

-    return (nfsreq);
+    return (pnfsreq);
 }

 process_status_t
-dispatch_rpc_subrequest(nfs_worker_data_t *mydata,
+dispatch_rpc_subrequest(nfs_worker_data_t *pmydata,
                         request_data_t *onfsreq)
 {
   char *cred_area;
   struct rpc_msg *msg;
   struct svc_req *req;
-  request_data_t *nfsreq = NULL;
+  request_data_t *pnfsreq = NULL;
   unsigned int worker_index;
   process_status_t rc = PROCESS_DONE;

   /* choose a worker who is not us */
-  worker_index = nfs_core_select_worker_queue(mydata->worker_index);
+  worker_index = nfs_core_select_worker_queue( pmydata->worker_index );

   LogDebug(COMPONENT_DISPATCH,
            "Use request from Worker Thread #%u's pool, xprt->xp_fd=%d, "
@@ -902,24 +902,34 @@ dispatch_rpc_subrequest(nfs_worker_data_t *mydata,
            worker_index, onfsreq->r_u.nfs->xprt->xp_fd,
            workers_data[worker_index].pending_request_len);

-  /* Get a nfsreq from the worker's pool */
-  nfsreq = pool_alloc(request_pool, NULL);
+  /* Get a pnfsreq from the worker's pool */
+  P(workers_data[worker_index].request_pool_mutex);

-  if(nfsreq == NULL)
+  GetFromPool(pnfsreq, &workers_data[worker_index].request_pool,
+              request_data_t);
+
+  V(workers_data[worker_index].request_pool_mutex);
+
+  if(pnfsreq == NULL)
     {
       LogMajor(COMPONENT_DISPATCH,
-               "Unable to allocate request. Exiting...");
+               "Empty request pool for the chosen worker ! Exiting...");
       Fatal();
     }

   /* Set the request as NFS already-read */
-  nfsreq->rtype = NFS_REQUEST;
+  pnfsreq->rtype = NFS_REQUEST;

   /* tranfer onfsreq */
-  nfsreq->r_u.nfs = onfsreq->r_u.nfs;
+  pnfsreq->r_u.nfs = onfsreq->r_u.nfs;

   /* And fixup onfsreq */
-  onfsreq->r_u.nfs = pool_alloc(request_data_pool, NULL);
+  P(pmydata->request_pool_mutex);
+
+  GetFromPool(onfsreq->r_u.nfs, &pmydata->request_data_pool,
+              nfs_request_data_t);
+
+  V(pmydata->request_pool_mutex);

   if(onfsreq->r_u.nfs == NULL)
     {
@@ -938,14 +948,14 @@ dispatch_rpc_subrequest(nfs_worker_data_t *mydata,
   req->rq_clntcred = &(cred_area[2 * MAX_AUTH_BYTES]);

   /* Set up xprt */
-  onfsreq->r_u.nfs->xprt = nfsreq->r_u.nfs->xprt;
+  onfsreq->r_u.nfs->xprt = pnfsreq->r_u.nfs->xprt;
   req->rq_xprt = onfsreq->r_u.nfs->xprt;

   /* count as 1 ref */
   gsh_xprt_ref(req->rq_xprt, XPRT_PRIVATE_FLAG_LOCKED);

   /* Hand it off */
-  DispatchWorkNFS(nfsreq, worker_index);
+  DispatchWorkNFS(pnfsreq, worker_index);

   return (rc);
 }
@@ -988,25 +998,25 @@ process_status_t dispatch_rpc_request(SVCXPRT *xprt)

   /* Get a nfsreq from the worker's pool */
   nfsreq = pool_alloc(request_pool, NULL);
-  nfsreq->r_u.nfs = pool_alloc(request_data_pool, NULL);

   if(nfsreq == NULL)
     {
       LogMajor(COMPONENT_DISPATCH,
-               "Unable to allocate request.  Exiting...");
+               "Empty request pool for the chosen worker ! Exiting...");
       Fatal();
     }

-  /* Set the request as NFS with xprt hand-off */
-  nfsreq->rtype = NFS_REQUEST_LEADER ;
-
+  nfsreq->r_u.nfs = pool_alloc(request_data_pool, NULL);
   if(nfsreq->r_u.nfs == NULL)
     {
       LogMajor(COMPONENT_DISPATCH,
-               "Unable to allocate request data. Exiting...");
+               "Empty request pool for the chosen worker ! Exiting...");
       Fatal();
     }

+  /* Set the request as NFS with xprt hand-off */
+  nfsreq->rtype = NFS_REQUEST_LEADER ;
+
   /* Set up cred area */
   cred_area = nfsreq->r_u.nfs->cred_area;
   preq = &(nfsreq->r_u.nfs->req);

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/MainNFSD/nfs_worker_thread.c b/src/MainNFSD/nfs_worker_thread.c
index 72234f1..50748c6 100644
--- a/src/MainNFSD/nfs_worker_thread.c
+++ b/src/MainNFSD/nfs_worker_thread.c
@@ -75,7 +75,6 @@
 extern nfs_worker_data_t *workers_data;

 pool_t *request_pool;
-pool_t *request_data_pool;
 pool_t *dupreq_pool;
 pool_t *ip_stats_pool;

@@ -751,7 +750,10 @@ int nfs_rpc_get_args(nfs_request_data_t *preqnfs, const nfs_function_desc_t *pfu
  *
  * This is the regular RPC dispatcher that every RPC server should include.
  *
- * @param[in,out] preq NFS request
+ * @param preq [INOUT] pointer to NFS request
+ * @param pworker_data [INOUT] worker data
+ *
+ * @return nothing (void function)
  *
  */
 static void nfs_rpc_execute(request_data_t *preq,
@@ -1394,7 +1396,7 @@ static void nfs_rpc_execute(request_data_t *preq,
         }
     }

-  /* Be careful (Issue #66) : it makes no sense to check access for
+  /* Be careful (Issue #66) : it makes no sense to check access for
    * a MOUNT request */
   if(req->rq_prog != nfs_param.core_param.program[P_MNT])
    {
@@ -1480,11 +1482,11 @@ static void nfs_rpc_execute(request_data_t *preq,
       /* Do the authentication stuff, if needed */
       if(pworker_data->pfuncdesc->dispatch_behaviour & NEEDS_CRED)
         {
-          /* Swap the anonymous uid/gid if the user should be anonymous */
+	  /* Swap the anonymous uid/gid if the user should be anonymous */
           if(nfs_check_anon(&related_client, pexport, &user_credentials) == FALSE
-             || nfs_build_fsal_context(req,
+	     || nfs_build_fsal_context(req,
                                        pexport,
-                                       &pworker_data->thread_fsal_context,
+				       &pworker_data->thread_fsal_context,
                                        &user_credentials) == FALSE)
             {
               LogInfo(COMPONENT_DISPATCH,
@@ -1543,7 +1545,7 @@ static void nfs_rpc_execute(request_data_t *preq,
   /* process time */
   stat_type = (rc == NFS_REQ_OK) ? GANESHA_STAT_SUCCESS : GANESHA_STAT_DROP;
   P(pworker_data->request_pool_mutex);
-  timer_diff = time_diff(*timer_start, timer_end);
+  timer_diff = time_diff(*timer_start, timer_end);
   V(pworker_data->request_pool_mutex);
   latency_stat.type = SVC_TIME;
   latency_stat.latency = timer_diff.tv_sec * 1000000
@@ -1767,7 +1769,7 @@ void DispatchWorkNFS(request_data_t *nfsreq, unsigned int worker_index)
   case NFS_CALL:
       break;
   default:
-      req = &nfsreq->r_u.nfs->req;
+      req = &pnfsreq->r_u.nfs->req;
       rpcxid = req->rq_xid;
   }

@@ -1830,7 +1832,7 @@ enum auth_stat AuthenticateRequest(nfs_request_data_t *nfsreq,
                (int)req->rq_prog, (int)req->rq_vers,
                (int)req->rq_proc, req->rq_xid, req->rq_xprt);

-  /* XXX Restore previously saved GssData.
+  /* XXX Restore previously saved GssData.
    * I'm not clear what we're restoring here.  Operating on xprt means that
    * we do (did) not share buffers with xprt_copy.
    */
@@ -1887,12 +1889,12 @@ static void _9p_execute( _9p_request_data_t * preq9p,
 #endif

 static inline enum xprt_stat
-cond_multi_dispatch(nfs_worker_data_t *pmydata, request_data_t *nfsreq,
+cond_multi_dispatch(nfs_worker_data_t *pmydata, request_data_t *pnfsreq,
                     bool *locked)
 {
     enum xprt_stat stat;
     bool_t try_multi = FALSE, dispatched = FALSE;
-    SVCXPRT *xprt = nfsreq->r_u.nfs->xprt;
+    SVCXPRT *xprt = pnfsreq->r_u.nfs->xprt;

     stat = SVC_STAT(xprt);
     svc_dplx_unlock_x(xprt, &pmydata->sigmask);
@@ -1921,7 +1923,7 @@ cond_multi_dispatch(nfs_worker_data_t *pmydata, request_data_t *nfsreq,
         if (xu->multi_cnt < nfs_param.core_param.dispatch_multi_xprt_max) {
             ++(xu->multi_cnt);
             /* dispatch it */
-            rc_multi = dispatch_rpc_subrequest(pmydata, nfsreq);
+            rc_multi = dispatch_rpc_subrequest(pmydata, pnfsreq);
             dispatched = TRUE;
         }
         pthread_rwlock_unlock(&xprt->lock);
@@ -1929,7 +1931,7 @@ cond_multi_dispatch(nfs_worker_data_t *pmydata, request_data_t *nfsreq,

     if (! dispatched) {
         /* Execute it */
-        nfs_rpc_execute(nfsreq, pmydata);
+        nfs_rpc_execute(pnfsreq, pmydata);
     }

     return (stat);
@@ -2058,9 +2060,8 @@ again:

       DISP_LOCK(xprt);
       if(AuthenticateRequest(nfsreq->r_u.nfs,
-                             &no_dispatch) != AUTH_OK || no_dispatch) {
+                             &no_dispatch) != AUTH_OK || no_dispatch)
           goto unblock;
-      }

       if(!nfs_rpc_get_args(nfsreq->r_u.nfs, pfuncdesc))
           goto unblock;
@@ -2069,7 +2070,7 @@ again:

       /* Validate the rpc request as being a valid program, version,
        * and proc. If not, report the error. Otherwise, execute the
-       * funtion. */
+       * funtion. */
       if(is_rpc_call_valid(preq->rq_xprt, preq) == TRUE)
           stat = cond_multi_dispatch(pmydata, nfsreq, &locked);

@@ -2127,6 +2128,7 @@ void *worker_thread(void *IndexArg)
   nfs_worker_data_t *pmydata = &(workers_data[worker_index]);
   char thr_name[32];
   gsh_xprt_private_t *xu = NULL;
+  int rc = 0;

 #ifdef _USE_SHARED_FSAL
   unsigned int i = 0 ;
@@ -2236,18 +2238,18 @@ void *worker_thread(void *IndexArg)

       P(pmydata->request_pool_mutex);
       nfsreq = glist_first_entry(&pmydata->pending_request, request_data_t,
-                                  pending_req_queue);
+                                 pending_req_queue);
       if (nfsreq == NULL) {
-        V(pmydata->request_pool_mutex);
-        LogMajor(COMPONENT_DISPATCH, "No pending request available");
-        continue;             /* return to main loop */
+	  V(pmydata->request_pool_mutex);
+	  LogMajor(COMPONENT_DISPATCH, "No pending request available");
+	  continue;             /* return to main loop */
       }
       glist_del(&nfsreq->pending_req_queue);
       pmydata->pending_request_len--;
       V(pmydata->request_pool_mutex);

       /* Check for destroyed xprts */
-      switch(nfsreq->rtype) {
+      switch( nfsreq->rtype ) {
       case NFS_REQUEST_LEADER:
       case NFS_REQUEST:
           xu = (gsh_xprt_private_t *) nfsreq->r_u.nfs->xprt->xp_u1;
@@ -2262,11 +2264,11 @@ void *worker_thread(void *IndexArg)
           break;
       }

-      switch(nfsreq->rtype)
+      switch( pnfsreq->rtype )
        {
           case NFS_REQUEST_LEADER:
               LogDebug(COMPONENT_DISPATCH,
-                       "Multi-dispatch leader, nfsreq=%p, pending=%d, "
+                       "Multi-dispatch leader, pnfsreq=%p, pending=%d, "
                        "xid=%u xprt=%p refcnt=%u",
                        nfsreq,
                        pmydata->pending_request_len,
@@ -2275,28 +2277,28 @@ void *worker_thread(void *IndexArg)
                        xu->refcnt);

            if(nfsreq->r_u.nfs->xprt->xp_fd == 0)
-             {
+           {
                LogFullDebug(COMPONENT_DISPATCH,
                             "RPC dispatch error:  nfsreq=%p, xp_fd==0",
                             nfsreq);
-             }
+            }
            else
-             {
-               /* Process the sequence */
-               (void) nfs_worker_process_rpc_requests(pmydata, nfsreq);
-             }
+           {
+              /* Process the sequence */
+              (void) nfs_worker_process_rpc_requests(pmydata, nfsreq);
+            }
            break;

        case NFS_REQUEST:
            LogDebug(COMPONENT_DISPATCH,
-                    "Multi-dispatch subrequest, nfsreq=%p, pending=%d, "
+                    "Multi-dispatch subrequest, pnfsreq=%p, pending=%d, "
                     "xid=%u xprt=%p refcnt=%u",
-                    nfsreq,
+                    pnfsreq,
                     pmydata->pending_request_len,
-                    nfsreq->r_u.nfs->msg.rm_xid,
-                    nfsreq->r_u.nfs->xprt,
+                    pnfsreq->r_u.nfs->msg.rm_xid,
+                    pnfsreq->r_u.nfs->xprt,
                     xu->refcnt);
-           nfs_rpc_execute(nfsreq, pmydata);
+           nfs_rpc_execute(pnfsreq, pmydata);
            break;

        case NFS_CALL:
@@ -2320,16 +2322,16 @@ void *worker_thread(void *IndexArg)
       LogInfo(COMPONENT_DISPATCH, "Signaling completion of request");

       /* Drop multi_cnt and xprt refcnt, if appropriate */
-      switch(nfsreq->rtype) {
+      switch( pnfsreq->rtype ) {
        case NFS_REQUEST_LEADER:
            gsh_xprt_unref(
-               nfsreq->r_u.nfs->xprt, XPRT_PRIVATE_FLAG_NONE);
+               pnfsreq->r_u.nfs->xprt, XPRT_PRIVATE_FLAG_NONE);
            break;
        case NFS_REQUEST:
-           pthread_rwlock_wrlock(&nfsreq->r_u.nfs->xprt->lock);
+           pthread_rwlock_wrlock(&pnfsreq->r_u.nfs->xprt->lock);
            --(xu->multi_cnt);
            gsh_xprt_unref(
-               nfsreq->r_u.nfs->xprt, XPRT_PRIVATE_FLAG_LOCKED);
+               pnfsreq->r_u.nfs->xprt, XPRT_PRIVATE_FLAG_LOCKED);
            break;
        case NFS_CALL:
            break;
@@ -2340,9 +2342,11 @@ void *worker_thread(void *IndexArg)
       /* Free the req by releasing the entry */
       LogFullDebug(COMPONENT_DISPATCH,
                    "Invalidating processed entry");
+      P(pmydata->request_pool_mutex);
       if (nfsreq->r_u.nfs)
         pool_free(request_data_pool, nfsreq->r_u.nfs);
       pool_free(request_pool, nfsreq);
+      V(pmydata->request_pool_mutex);

       if(pmydata->passcounter > nfs_param.worker_param.nb_before_gc)
         {

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/Protocols/DBUS/dbus_server.c b/src/Protocols/DBUS/dbus_server.c
index 5c73b9c..d034a9a 100644
--- a/src/Protocols/DBUS/dbus_server.c
+++ b/src/Protocols/DBUS/dbus_server.c
@@ -43,6 +43,7 @@
 #if defined(USE_DBUS)
 #include <dbus/dbus.h>
 #endif /* USE_DBUS */
+#include "stuff_alloc.h"
 #include "nlm_list.h"
 #include "fsal.h"
 #include "nfs_core.h"
@@ -167,8 +168,8 @@ int32_t gsh_dbus_register_path(const char *name,
     snprintf(path, 512, "/org/ganesha/nfsd/%s", name);

     handler = (ganesha_dbus_handler_t *)
-        gsh_malloc(sizeof(ganesha_dbus_handler_t));
-    handler->name = gsh_strdup(path);
+        Mem_Alloc(sizeof(ganesha_dbus_handler_t));
+    handler->name = Str_Dup(path);
     handler->vtable.unregister_function = path_unregistered_func;
     handler->vtable.message_function =  method;

@@ -185,7 +186,7 @@ int32_t gsh_dbus_register_path(const char *name,
     if (! code) {
         LogFatal(COMPONENT_DBUS, "dbus_connection_register_object_path "
                  "failed");
-        gsh_free(handler);
+        Mem_Free(handler);
         goto out;
     }

@@ -222,8 +223,8 @@ void gsh_dbus_pkgshutdown(void)
                         handler->name, thread_state.dbus_err.message);
                 dbus_error_free(&thread_state.dbus_err);
             }
-            gsh_free(handler->name);
-            gsh_free(handler);
+            Mem_Free(handler->name);
+            Mem_Free(handler);
         }
     } while ((onode = node) && (node = avltree_next(node)));
     if (onode) {
@@ -236,8 +237,8 @@ void gsh_dbus_pkgshutdown(void)
                     handler->name, thread_state.dbus_err.message);
             dbus_error_free(&thread_state.dbus_err);
         }
-        gsh_free(handler->name);
-        gsh_free(handler);
+        Mem_Free(handler->name);
+        Mem_Free(handler);
     }
     avltree_init(&thread_state.callouts, dbus_callout_cmpf, 0);

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/Protocols/NFS/nfs41_op_close.c b/src/Protocols/NFS/nfs41_op_close.c
index 621c4b2..6079b61 100644
--- a/src/Protocols/NFS/nfs41_op_close.c
+++ b/src/Protocols/NFS/nfs41_op_close.c
@@ -203,6 +203,7 @@ int nfs41_op_close(struct nfs_argop4 *op, compound_data_t * data,
               pstate->state_data.layout.state_return_on_close)
             {
               nfs4_return_one_state(data->current_entry,
+                                    data->pclient,
                                     data->pcontext,
                                     TRUE,
                                     FALSE,

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/Protocols/NFS/nfs41_op_create_session.c b/src/Protocols/NFS/nfs41_op_create_session.c
index 6cb039c..63fa06c 100644
--- a/src/Protocols/NFS/nfs41_op_create_session.c
+++ b/src/Protocols/NFS/nfs41_op_create_session.c
@@ -43,6 +43,7 @@

 #include <pthread.h>
 #include "log.h"
+#include "stuff_alloc.h"
 #include "nfs4.h"
 #include "nfs_core.h"
 #include "nfs_exports.h"
@@ -51,15 +52,15 @@

 /**
  *
- * @brief The NFS4_OP_CREATE_SESSION operation.
+ * nfs4_op_create_session:  The NFS4_OP_CREATE_SESSION operation.
  *
  * The NFS4_OP_CREATE_SESSION operation.
  *
- * @param[in]     op    nfs4_op arguments
- * @param[in,out] data  Compound request's data
- * @param[out]    resp  nfs4_op results
+ * @param op    [IN]    pointer to nfs4_op arguments
+ * @param data  [INOUT] Pointer to the compound request's data
+ * @param resp  [IN]    Pointer to nfs4_op results
  *
- * @return NFS4_OK if successfull, other values show an error.
+ * @return NFS4_OK if successfull, other values show an error.
  *
  * @see nfs4_Compound
  *
@@ -72,8 +73,9 @@ int nfs41_op_create_session(struct nfs_argop4 *op,
   nfs_client_id_t     * punconf = NULL;
   nfs_client_id_t     * pfound  = NULL;
   nfs_client_record_t * pclient_record;
-  nfs41_session_t     * nfs41_session = NULL;
+  nfs41_session_t     * pnfs41_session = NULL;
   clientid4             clientid = 0;
+  nfs_worker_data_t   * pworker = NULL;
   sockaddr_t            client_addr;
   char                  str_client_addr[SOCK_NAME_MAX];
   char                  str_client[NFS4_OPAQUE_LIMIT * 2 + 1];
@@ -83,6 +85,8 @@ int nfs41_op_create_session(struct nfs_argop4 *op,
   if(isDebug(COMPONENT_SESSIONS))
     component = COMPONENT_SESSIONS;

+  pworker = (nfs_worker_data_t *) data->pclient->pworker;
+
 #define arg_CREATE_SESSION4 op->nfs_argop4_u.opcreate_session
 #define res_CREATE_SESSION4 resp->nfs_resop4_u.opcreate_session
 #define res_CREATE_SESSION4ok res_CREATE_SESSION4.CREATE_SESSION4res_u.csr_resok4
@@ -279,9 +283,9 @@ int nfs41_op_create_session(struct nfs_argop4 *op,
     }

   /* Record session related information at the right place */
-  nfs41_session = pool_alloc(nfs41_session_pool, NULL);
+  GetFromPool(pnfs41_session, &data->pclient->pool_session, nfs41_session_t);

-  if(nfs41_session == NULL)
+  if(pnfs41_session == NULL)
     {
       LogDebug(component,
                "Could not allocate memory for a session");
@@ -293,34 +297,33 @@ int nfs41_op_create_session(struct nfs_argop4 *op,
       goto out;
     }

-  nfs41_session->clientid           = clientid;
-  nfs41_session->pclientid_record   = pfound;
-  nfs41_session->sequence           = arg_CREATE_SESSION4.csa_sequence;
-  nfs41_session->session_flags      = CREATE_SESSION4_FLAG_CONN_BACK_CHAN;
-  nfs41_session->fore_channel_attrs = arg_CREATE_SESSION4.csa_fore_chan_attrs;
-  nfs41_session->back_channel_attrs = arg_CREATE_SESSION4.csa_back_chan_attrs;
+  memset((char *)pnfs41_session, 0, sizeof(nfs41_session_t));
+
+  pnfs41_session->clientid           = clientid;
+  pnfs41_session->pclientid_record   = pfound;
+  pnfs41_session->sequence           = arg_CREATE_SESSION4.csa_sequence;
+  pnfs41_session->session_flags      = CREATE_SESSION4_FLAG_CONN_BACK_CHAN;
+  pnfs41_session->fore_channel_attrs = arg_CREATE_SESSION4.csa_fore_chan_attrs;
+  pnfs41_session->back_channel_attrs = arg_CREATE_SESSION4.csa_back_chan_attrs;

   /* Take reference to clientid record */
   inc_client_id_ref(pfound);

   /* Set ca_maxrequests */
-  nfs41_session->fore_channel_attrs.ca_maxrequests = NFS41_NB_SLOTS;
-  nfs41_session->fore_channel_attrs.ca_maxrequests = NFS41_NB_SLOTS;
+  pnfs41_session->fore_channel_attrs.ca_maxrequests = NFS41_NB_SLOTS;
+  pnfs41_session->fore_channel_attrs.ca_maxrequests = NFS41_NB_SLOTS;

-  nfs41_Build_sessionid(&clientid, nfs41_session->session_id);
+  nfs41_Build_sessionid(&clientid, pnfs41_session->session_id);

-  res_CREATE_SESSION4ok.csr_sequence = nfs41_session->sequence;
+  res_CREATE_SESSION4ok.csr_sequence = pnfs41_session->sequence;
   res_CREATE_SESSION4ok.csr_flags    = CREATE_SESSION4_FLAG_CONN_BACK_CHAN;

-  /* return the input for wanting of something better (will change in
-     later versions) */
-  res_CREATE_SESSION4ok.csr_fore_chan_attrs
-       = nfs41_session->fore_channel_attrs;
-  res_CREATE_SESSION4ok.csr_back_chan_attrs
-       = nfs41_session->back_channel_attrs;
+  /* return the input for wanting of something better (will change in later versions) */
+  res_CREATE_SESSION4ok.csr_fore_chan_attrs = pnfs41_session->fore_channel_attrs;
+  res_CREATE_SESSION4ok.csr_back_chan_attrs = pnfs41_session->back_channel_attrs;

   memcpy(res_CREATE_SESSION4ok.csr_sessionid,
-         nfs41_session->session_id,
+         pnfs41_session->session_id,
          NFS4_SESSIONID_SIZE);

   /* Create Session replay cache */
@@ -329,7 +332,7 @@ int nfs41_op_create_session(struct nfs_argop4 *op,

   LogDebug(component, "CREATE_SESSION replay=%p", data->pcached_res);

-  if(!nfs41_Session_Set(nfs41_session->session_id, nfs41_session))
+  if(!nfs41_Session_Set(pnfs41_session->session_id, pnfs41_session))
     {
       LogDebug(component,
                "Could not insert session into table");
@@ -339,7 +342,7 @@ int nfs41_op_create_session(struct nfs_argop4 *op,
       dec_client_id_ref(pfound);

       /* Free the memory for the session */
-      pool_free(nfs41_session_pool, nfs41_session);
+      ReleaseToPool(pnfs41_session, &data->pclient->pool_session);

       res_CREATE_SESSION4.csr_status = NFS4ERR_SERVERFAULT;     /* Maybe a more precise status would be better */

@@ -442,7 +445,8 @@ int nfs41_op_create_session(struct nfs_argop4 *op,
             res_CREATE_SESSION4.csr_status = NFS4ERR_RESOURCE;

           /* Need to destroy the session */
-          if(!nfs41_Session_Del(nfs41_session->session_id))
+          if(!nfs41_Session_Del(pnfs41_session->session_id,
+                                &data->pclient->pool_session))
             LogDebug(component,
                      "Oops nfs41_Session_Del failed");

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/Protocols/NFS/nfs41_op_destroy_session.c b/src/Protocols/NFS/nfs41_op_destroy_session.c
index 1b0251c..cf098dd 100644
--- a/src/Protocols/NFS/nfs41_op_destroy_session.c
+++ b/src/Protocols/NFS/nfs41_op_destroy_session.c
@@ -10,25 +10,27 @@
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 3 of the License, or (at your option) any later version.
- *
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- *
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- *
+ *
  * ---------------------------------------
  */

 /**
  * \file    nfs4_op_destroy_session.c
+ * \author  $Author: deniel $
+ * \date    $Date: 2009/08/19 17:02:52 $
  * \brief   Routines used for managing the NFS4_OP_DESTROY_SESSION operation.
  *
- * Routines used for managing the NFS4_OP_DESTROY_SESSION operation.
- *
+ * nfs4_op_destroy_session.c :  Routines used for managing the NFS4_OP_DESTROY_SESSION operation.
+ *
  *
  */
 #ifdef HAVE_CONFIG_H
@@ -43,15 +45,15 @@

 /**
  *
- * @brief The NFS4_OP_DESTROY_SESSION operation.
+ * nfs4_op_destroy_session:  The NFS4_OP_DESTROY_SESSION operation.
  *
  * The NFS4_OP_DESTROY_SESSION operation.
  *
- * @param[in]     op   nfs4_op arguments
- * @param[in,out] data Compound request's data
- * @param[out]    resp nfs4_op results
+ * @param op    [IN]    pointer to nfs4_op arguments
+ * @param data  [INOUT] Pointer to the compound request's data
+ * @param resp  [IN]    Pointer to nfs4_op results
  *
- * @return NFS4_OK if successfull, other values show an error.
+ * @return NFS4_OK if successfull, other values show an error.
  *
  * @see nfs4_Compound
  *
@@ -67,7 +69,8 @@ int nfs41_op_destroy_session(struct nfs_argop4 *op,
   resp->resop = NFS4_OP_DESTROY_SESSION;
   res_DESTROY_SESSION4.dsr_status = NFS4_OK;

-  if(!nfs41_Session_Del(arg_DESTROY_SESSION4.dsa_sessionid))
+  if(!nfs41_Session_Del(arg_DESTROY_SESSION4.dsa_sessionid,
+                        &data->pclient->pool_session))
     res_DESTROY_SESSION4.dsr_status = NFS4ERR_BADSESSION;
   else
     res_DESTROY_SESSION4.dsr_status = NFS4_OK;
@@ -77,13 +80,13 @@ int nfs41_op_destroy_session(struct nfs_argop4 *op,

 /**
  * nfs41_op_destroy_session_Free: frees what was allocared to handle nfs41_op_destroy_session.
- *
+ *
  * Frees what was allocared to handle nfs41_op_destroy_session.
  *
  * @param resp  [INOUT]    Pointer to nfs4_op results
  *
  * @return nothing (void function )
- *
+ *
  */
 void nfs41_op_destroy_session_Free(DESTROY_SESSION4res * resp)
 {

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/Protocols/NFS/nfs41_op_exchange_id.c b/src/Protocols/NFS/nfs41_op_exchange_id.c
index 3f350ee..c3157e9 100644
--- a/src/Protocols/NFS/nfs41_op_exchange_id.c
+++ b/src/Protocols/NFS/nfs41_op_exchange_id.c
@@ -7,29 +7,30 @@
  *
  *
  * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  * ---------------------------------------
  */

 /**
  * \file    nfs41_op_exchange_id.c
+ * \author  $Author: deniel $
+ * \date    $Date: 2009/08/19 16:02:52 $
  * \brief   Routines used for managing the NFS4_OP_EXCHANGE_ID operation.
  *
- * Routines used for managing the EXCHANGE_ID operation.
- *
+ * nfs4_op_exchange_id.c :  Routines used for managing the EXCHANGE_ID operation.
+ *
  *
  */
 #ifdef HAVE_CONFIG_H
@@ -42,6 +43,7 @@

 #include <pthread.h>
 #include "log.h"
+#include "stuff_alloc.h"
 #include "nfs4.h"
 #include "mount.h"
 #include "nfs_core.h"
@@ -355,7 +357,8 @@ int nfs41_op_exchange_id(struct nfs_argop4 *op,
   punconf = create_client_id(0,
                              pclient_record,
                              &client_addr,
-                             &data->credential);
+                             &data->credential,
+                             data->pclient);

   if(punconf == NULL)
     {
@@ -425,7 +428,7 @@ int nfs41_op_exchange_id(struct nfs_argop4 *op,
   res_EXCHANGE_ID4_ok.eir_state_protect.spr_how = SP4_NONE;

   len  = strlen(punconf->cid_server_owner);
-  temp = gsh_malloc(len);
+  temp = Mem_Alloc(len);
   if(temp == NULL)
     {
       LogDebug(component,
@@ -441,7 +444,7 @@ int nfs41_op_exchange_id(struct nfs_argop4 *op,
   res_EXCHANGE_ID4_ok.eir_server_owner.so_minor_id = 0;

   len  = strlen(punconf->cid_server_scope);
-  temp = gsh_malloc(len);
+  temp = Mem_Alloc(len);
   if(temp == NULL)
     {
       LogDebug(component,
@@ -499,12 +502,12 @@ void nfs41_op_exchange_id_Free(EXCHANGE_ID4res * resp)
 {
   if(resp->eir_status == NFS4_OK)
     {
-      if(resp->EXCHANGE_ID4res_u.eir_resok4.eir_server_scope.eir_server_scope_val != NULL)
-        gsh_free(resp->EXCHANGE_ID4res_u.eir_resok4.eir_server_scope.eir_server_scope_val);
-      if(resp->EXCHANGE_ID4res_u.eir_resok4.eir_server_owner.so_major_id.so_major_id_val != NULL)
-        gsh_free(resp->EXCHANGE_ID4res_u.eir_resok4.eir_server_owner.so_major_id.so_major_id_val);
-      if(resp->EXCHANGE_ID4res_u.eir_resok4.eir_server_impl_id.eir_server_impl_id_val != NULL)
-        gsh_free(resp->EXCHANGE_ID4res_u.eir_resok4.eir_server_impl_id.eir_server_impl_id_val);
+        gsh_free(resp->EXCHANGE_ID4res_u.eir_resok4.eir_server_scope
+                 .eir_server_scope_val);
+        gsh_free(resp->EXCHANGE_ID4res_u.eir_resok4.eir_server_owner.so_major_id
+                 .so_major_id_val);
+        gsh_free(resp->EXCHANGE_ID4res_u.eir_resok4.eir_server_impl_id
+                 .eir_server_impl_id_val);
     }
   return;
 }                               /* nfs41_op_exchange_id_Free */

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
diff --git a/src/Protocols/NFS/nfs41_op_layoutcommit.c b/src/Protocols/NFS/nfs41_op_layoutcommit.c
index 241a12d..9d3257b 100644
--- a/src/Protocols/NFS/nfs41_op_layoutcommit.c
+++ b/src/Protocols/NFS/nfs41_op_layoutcommit.c
@@ -221,7 +221,11 @@ int nfs41_op_layoutcommit(struct nfs_argop4 *op, compound_data_t * data,
      if (arg_LAYOUTCOMMIT4.loca_time_modify.nt_timechanged ||
          arg_LAYOUTCOMMIT4.loca_last_write_offset.no_newoffset ||
          res.size_supplied) {
-          if (cache_inode_kill_entry(data->current_entry))
+          if (cache_inode_kill_entry(data->current_entry,
+                                     WT_LOCK,
+                                     data->ht,
+                                     data->pclient,
+                                     &cache_status)
               != CACHE_INODE_SUCCESS) {
                nfs_status = nfs4_Errno(cache_status);
                goto out;

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/Protocols/NFS/nfs41_op_layoutget.c b/src/Protocols/NFS/nfs41_op_layoutget.c
index 131ce53..3c11cac 100644
--- a/src/Protocols/NFS/nfs41_op_layoutget.c
+++ b/src/Protocols/NFS/nfs41_op_layoutget.c
@@ -261,6 +261,7 @@ out:

           if ((layout_state) && (layout_state->state_seqid == 0)) {
                state_del(layout_state,
+                         data->pclient,
                          &state_status);
                layout_state = NULL;
           }
@@ -389,6 +390,7 @@ acquire_layout_state(compound_data_t *data,
                };
                if ((nfs_status
                     = nfs4_return_one_state(data->current_entry,
+                                            data->pclient,
                                             data->pcontext,
                                             TRUE,
                                             FALSE,
@@ -417,6 +419,7 @@ acquire_layout_state(compound_data_t *data,
                         STATE_TYPE_LAYOUT,
                         &layout_data,
                         clientid_owner,
+                        data->pclient,
                         data->pcontext,
                         layout_state,
                         &state_status) != STATE_SUCCESS) {

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
REBASEME
Fix

diff --git a/src/Protocols/NFS/nfs41_op_sequence.c b/src/Protocols/NFS/nfs41_op_sequence.c
index 6c49519..718b3ff 100644
--- a/src/Protocols/NFS/nfs41_op_sequence.c
+++ b/src/Protocols/NFS/nfs41_op_sequence.c
@@ -7,28 +7,28 @@
  *
  *
  * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- *
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
  * ---------------------------------------
  */

 /**
  * \file    nfs41_op_sequence.c
+ * \author  $Author: deniel $
  * \brief   Routines used for managing the NFS4_OP_SEQUENCE operation.
  *
- * Routines used for managing the NFS4_OP_SEQUENCE operation.
+ * nfs41_op_sequence.c : Routines used for managing the NFS4_OP_SEQUENCE operation.
  *
  *
  */
@@ -44,14 +44,13 @@

 /**
  *
- * @brief the NFS4_OP_SEQUENCE operation
+ * nfs41_op_sequence: the NFS4_OP_SEQUENCE operation
  *
- * This functions handles the NFS4_OP_SEQUENCE operation in
- * NFSv4. This function can be called only from nfs4_Compound.
+ * This functions handles the NFS4_OP_SEQUENCE operation in NFSv4. This function can be called only from nfs4_Compound.
  *
- * @param[in]     op   nfs4_op arguments
- * @param[in,out] data Compound request's data
- * @param[out]    resp nfs4_op results
+ * @param op    [IN]    pointer to nfs4_op arguments
+ * @param data  [INOUT] Pointer to the compound request's data
+ * @param resp  [IN]    Pointer to nfs4_op results
  *
  * @return NFS4_OK if successfull, other values show an error.
  *

Signed-off-by: Matt Benjamin <matt@linuxbox.com>