Пример #1
0
void remove_nfs4_owner(cache_inode_client_t * pclient,
                       state_owner_t        * powner,
                       const char           * str)
{
  hash_buffer_t           buffkey, old_key, old_value;
  state_nfs4_owner_name_t oname;
  int                     rc;

  oname.son_clientid  = powner->so_owner.so_nfs4_owner.so_clientid;
  oname.son_owner_len = powner->so_owner_len;
  oname.son_islock    = powner->so_type == STATE_LOCK_OWNER_NFSV4;
  memcpy(oname.son_owner_val, powner->so_owner_val, powner->so_owner_len);

  buffkey.pdata = (caddr_t) &oname;
  buffkey.len   = sizeof(*powner);

  rc = HashTable_DelRef(ht_nfs4_owner,
                        &buffkey,
                        &old_key,
                        &old_value,
                        Hash_dec_state_owner_ref);

  switch(rc)
    {
      case HASHTABLE_SUCCESS:
        if(powner->so_type == STATE_LOCK_OWNER_NFSV4)
          dec_state_owner_ref(powner->so_owner.so_nfs4_owner.so_related_owner, pclient);

        /* Release the owner_name (key) and owner (data) back to appropriate pools */
        LogFullDebug(COMPONENT_STATE, "Free %s", str);

        nfs4_Compound_FreeOne(&powner->so_owner.so_nfs4_owner.so_resp);
        ReleaseToPool(old_value.pdata, &pclient->pool_state_owner);
        ReleaseToPool(old_key.pdata, &pclient->pool_nfs4_owner_name);
        break;

      case HASHTABLE_NOT_DELETED:
        /* ref count didn't end up at 0, don't free. */
        LogDebug(COMPONENT_STATE,
                 "HashTable_DelRef didn't reduce refcount to 0 for %s",
                  str);
        break;

      default:
        /* some problem occurred */
        LogDebug(COMPONENT_STATE,
                 "HashTable_DelRef failed (%s) for %s",
                  hash_table_err_to_str(rc), str);
        break;
    }
}
Пример #2
0
/**
 * @brief Copy a operation into a state owner
 *
 * This is only used for NFSv4.0 and only for a specific subset of
 * operations for which it guarantees At-Most Once Semantics.
 *
 * @param[in,out] owner The owner to hold the operation
 * @param[in]     seqid Seqid of this operation
 * @param[in]     args  Arguments of operation to copy
 * @param[in]     data  Compound data
 * @param[in]     resp  Response to copy
 * @param[in]     tag   Arbitrary string for logging/debugging
 */
void Copy_nfs4_state_req(state_owner_t *owner,
                         seqid4 seqid,
                         nfs_argop4 *args,
                         cache_entry_t *entry,
                         nfs_resop4 *resp,
                         const char *tag)
{
  /* Simplify use of this function when we may not be keeping any data for the
   * state owner
   */
  if(owner == NULL)
    return;

  LogFullDebug(COMPONENT_STATE,
               "%s: saving response %p so_seqid %u new seqid %u",
               tag, owner, owner->so_owner.so_nfs4_owner.so_seqid, seqid);

  /* Free previous response */
  nfs4_Compound_FreeOne(&owner->so_owner.so_nfs4_owner.so_resp);

  /* Copy new response */
  nfs4_Compound_CopyResOne(&owner->so_owner.so_nfs4_owner.so_resp, resp);

  /* Deep copy OPEN args? */
  if(owner->so_owner.so_nfs4_owner.so_args.argop == NFS4_OP_OPEN)
    {
    }

  /* Copy bnew args */
  memcpy(&owner->so_owner.so_nfs4_owner.so_args,
         args,
         sizeof(owner->so_owner.so_nfs4_owner.so_args));

  /* Copy new file, note we don't take any reference, so this entry
   * might not remain valid, but the pointer value suffices here.
   */
  owner->so_owner.so_nfs4_owner.so_last_entry = entry;

  /* Deep copy OPEN args? */
  if(args->argop == NFS4_OP_OPEN)
    {
    }

  /* Store new seqid */
  owner->so_owner.so_nfs4_owner.so_seqid = seqid;
}
Пример #3
0
void free_nfs4_owner(state_owner_t * owner)
{
  if(owner->so_owner.so_nfs4_owner.so_related_owner != NULL)
    dec_state_owner_ref(owner->so_owner.so_nfs4_owner.so_related_owner);

  /* Release the saved response. */
  nfs4_Compound_FreeOne(&owner->so_owner.so_nfs4_owner.so_resp);

  /* Remove the owner from the owners per clientid list. */
  P(owner->so_owner.so_nfs4_owner.so_clientrec->cid_mutex);

  glist_del(&owner->so_owner.so_nfs4_owner.so_perclient);

  V(owner->so_owner.so_nfs4_owner.so_clientrec->cid_mutex);

  dec_client_id_ref(owner->so_owner.so_nfs4_owner.so_clientrec);
}
Пример #4
0
void Copy_nfs4_state_req(state_owner_t   * powner,
                         seqid4            seqid,
                         nfs_argop4      * args,
                         compound_data_t * data,
                         nfs_resop4      * resp,
                         const char      * tag)
{
  /* Simplify use of this function when we may not be keeping any data for the
   * state owner
   */
  if(powner == NULL)
    return;

  LogFullDebug(COMPONENT_STATE,
               "%s: saving response %p so_seqid %u new seqid %u",
               tag, powner, powner->so_owner.so_nfs4_owner.so_seqid, seqid);

  /* Free previous response */
  nfs4_Compound_FreeOne(&powner->so_owner.so_nfs4_owner.so_resp);

  /* Copy new response */
  nfs4_Compound_CopyResOne(&powner->so_owner.so_nfs4_owner.so_resp, resp);

  /* Deep copy OPEN args? */
  if(powner->so_owner.so_nfs4_owner.so_args.argop == NFS4_OP_OPEN)
    {
    }

  /* Copy bnew args */
  memcpy(&powner->so_owner.so_nfs4_owner.so_args,
         args,
         sizeof(powner->so_owner.so_nfs4_owner.so_args));

  /* Copy new file */
  powner->so_owner.so_nfs4_owner.so_last_pentry = data->current_entry;

  /* Deep copy OPEN args? */
  if(args->argop == NFS4_OP_OPEN)
    {
    }

  /* Store new seqid */
  powner->so_owner.so_nfs4_owner.so_seqid = seqid;
}
Пример #5
0
void free_nfs4_owner(state_owner_t *owner)
{
	state_nfs4_owner_t *nfs4_owner = &owner->so_owner.so_nfs4_owner;

	if (nfs4_owner->so_related_owner != NULL)
		dec_state_owner_ref(nfs4_owner->so_related_owner);

	/* Release the saved response. */
	nfs4_Compound_FreeOne(&nfs4_owner->so_resp);

	/* Remove the owner from the owners per clientid list. */
	PTHREAD_MUTEX_lock(&nfs4_owner->so_clientrec->cid_mutex);

	glist_del(&nfs4_owner->so_perclient);

	PTHREAD_MUTEX_unlock(&nfs4_owner->so_clientrec->cid_mutex);

	dec_client_id_ref(nfs4_owner->so_clientrec);
}