nfs4_dispatch.c revision 7c46fb7fef68117215a0c60a64149aaea1a38578
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <rpc/auth_unix.h>
#include <rpc/auth_des.h>
#include <nfs/nfs_dispatch.h>
#include <nfs/nfs4_drc.h>
/*
* This is the duplicate request cache for NFSv4
*/
/*
* How long the entry can remain in the cache
* once it has been sent to the client and not
* used in a reply (in seconds)
*/
unsigned nfs4_drc_lifetime = 1;
/*
* The default size of the duplicate request cache
*/
/*
* The number of buckets we'd like to hash the
* replies into.. do not change this on the fly.
*/
/*
* Initialize a duplicate request cache.
*/
{
}
return (drc);
}
/*
* Destroy a duplicate request cache.
*/
void
{
/* iterate over the dr_cache and free the enties */
}
}
/*
* rfs4_dr_chstate:
*
* Change the state of a rfs4_dupreq. If it's not in transition
* to the FREE state, update the time used and return. If we
* are moving to the FREE state then we need to clean up the
* compound results and move the entry to the end of the list.
*/
void
{
if (new_state != NFS4_DUP_FREE) {
return;
}
/*
* Remove entry from the bucket and
* dr_cache list, free compound results.
*/
}
/*
* rfs4_alloc_dr:
*
* Pick an entry off the tail -- Use if it is
* marked NFS4_DUP_FREE, or is an entry in the
* NFS4_DUP_REPLAY state that has timed-out...
* Otherwise malloc a new one if we have not reached
* our maximum cache limit.
*
* The list should be in time order, so no need
* to traverse backwards looking for a timed out
* entry, NFS4_DUP_FREE's are place on the tail.
*/
{
case NFS4_DUP_FREE:
rfs4_dupreq_t *, drp_tail);
return (drp_tail);
/* NOTREACHED */
case NFS4_DUP_REPLAY:
if (gethrestime_sec() >
/* this entry has timedout so grab it. */
rfs4_dupreq_t *, drp_tail);
return (drp_tail);
}
break;
}
}
/*
* Didn't find something to recycle have
* we hit the cache limit ?
*/
rfs4_drc_t *, drc);
return (NULL);
}
/* nope, so let's malloc a new one */
return (drp);
}
/*
* rfs4_find_dr:
*
* Search for an entry in the duplicate request cache by
* calculating the hash index based on the XID, and examining
* the entries in the hash bucket. If we find a match stamp the
* time_used and return. If the entry does not match it could be
* ready to be freed. Once we have searched the bucket and we
* have not exhausted the maximum limit for the cache we will
* allocate a new entry.
*/
int
{
int bktdex;
/*
* Get the XID, calculate the bucket and search to
* see if we need to replay from the cache.
*/
int, bktdex,
/*
* Search the bucket for a matching xid and address.
*/
/*
* Found a match so REPLAY the Reply
*/
rfs4_dupreq_t *, drp);
return (NFS4_DUP_REPLAY);
}
/*
* This entry must be in transition, so return
* the 'pending' status.
*/
return (NFS4_DUP_PENDING);
}
/*
* Not a match, but maybe this entry is ready
* to be reused.
*/
(gethrestime_sec() >
}
}
return (NFS4_DUP_ERROR);
}
/*
* Place at the head of the list, init the state
* to NEW and clear the time used field.
*/
/*
* If needed, resize the address buffer
*/
/*
* If the malloc fails, mark the entry
* as free and put on the tail.
*/
return (NFS4_DUP_ERROR);
}
}
/*
* Copy the address.
*/
/*
* Insert at the head of the bucket and
* the drc lists..
*/
return (NFS4_DUP_NEW);
}
/*
*
* This function handles the duplicate request cache,
* NULL_PROC and COMPOUND procedure calls for NFSv4;
*
* Passed into this function are:-
*
* disp A pointer to our dispatch table entry
* req The request to process
* xprt The server transport handle
* ap A pointer to the arguments
*
*
* When appropriate this function is responsible for inserting
* the reply into the duplicate cache or replaying an existing
* cached reply.
*
* dr_stat reflects the state of the duplicate request that
* has been inserted into or retrieved from the cache
*
* drp is the duplicate request entry
*
*/
int
{
int error = 0;
int dis_flags = 0;
int dr_stat = NFS4_NOT_DUP;
/*
* Short circuit the RPC_NULL proc.
*/
return (1);
}
return (0);
}
/* Only NFSv4 Compounds from this point onward */
/*
* Figure out the disposition of the whole COMPOUND
* and record it's IDEMPOTENTCY.
*/
/*
* If NON-IDEMPOTENT then we need to figure out if this
* request can be replied from the duplicate cache.
*
* If this is a new request then we need to insert the
* reply into the duplicate cache.
*/
if (!(dis_flags & RPC_IDEMPOTENT)) {
/* look for a replay from the cache or allocate */
switch (dr_stat) {
case NFS4_DUP_ERROR:
return (1);
/* NOTREACHED */
case NFS4_DUP_PENDING:
/*
* reply has previously been inserted into the
* duplicate cache, however the reply has
* not yet been sent via svc_sendreply()
*/
return (1);
/* NOTREACHED */
case NFS4_DUP_NEW:
/* NON-IDEMPOTENT proc call */
/*
* mark this entry as FREE and plop
* on the end of the cache list
*/
return (1);
}
break;
case NFS4_DUP_REPLAY:
/* replay from the cache */
break;
}
} else {
/* IDEMPOTENT proc call */
return (1);
}
}
/*
* Send out the replayed reply or the 'real' one.
*/
char *, rbp);
error++;
}
/*
* If this reply was just inserted into the duplicate cache
* mark it as available for replay
*/
if (dr_stat == NFS4_DUP_NEW) {
} else if (dr_stat == NFS4_NOT_DUP) {
}
return (error);
}