5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
24 * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
25 */
26
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
29
30 /*
31 * Portions of this source code were derived from Berkeley 4.3 BSD
32 * under license from the Regents of the University of California.
33 */
34
35 /*
36 * svc_cots.c
37 * Server side for connection-oriented RPC in the kernel.
38 *
39 */
40
41 #include <sys/param.h>
42 #include <sys/types.h>
43 #include <sys/sysmacros.h>
44 #include <sys/file.h>
696
697 cd = (cots_data_t *)clone_xprt->xp_p2buf;
698 if ((mp = cd->cd_mp) != NULL) {
699 XDR_DESTROY(&clone_xprt->xp_xdrout);
700 cd->cd_mp = (mblk_t *)NULL;
701 freemsg(mp);
702 }
703 }
704
705 /*
706 * the dup cacheing routines below provide a cache of non-failure
707 * transaction id's. rpc service routines can use this to detect
708 * retransmissions and re-send a non-failure response.
709 */
710
711 /*
712 * MAXDUPREQS is the number of cached items. It should be adjusted
713 * to the service load so that there is likely to be a response entry
714 * when the first retransmission comes in.
715 */
716 #define MAXDUPREQS 1024
717
718 /*
719 * This should be appropriately scaled to MAXDUPREQS.
720 */
721 #define DRHASHSZ 257
722
723 #if ((DRHASHSZ & (DRHASHSZ - 1)) == 0)
724 #define XIDHASH(xid) ((xid) & (DRHASHSZ - 1))
725 #else
726 #define XIDHASH(xid) ((xid) % DRHASHSZ)
727 #endif
728 #define DRHASH(dr) XIDHASH((dr)->dr_xid)
729 #define REQTOXID(req) ((req)->rq_xprt->xp_xid)
730
731 static int cotsndupreqs = 0;
732 int cotsmaxdupreqs = MAXDUPREQS;
733 static kmutex_t cotsdupreq_lock;
734 static struct dupreq *cotsdrhashtbl[DRHASHSZ];
735 static int cotsdrhashstat[DRHASHSZ];
736
737 static void unhash(struct dupreq *);
738
739 /*
740 * cotsdrmru points to the head of a circular linked list in lru order.
741 * cotsdrmru->dr_next == drlru
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
24 * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
25 * Copyright (c) 2012 by Delphix. All rights reserved.
26 */
27
28 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
29 /* All Rights Reserved */
30
31 /*
32 * Portions of this source code were derived from Berkeley 4.3 BSD
33 * under license from the Regents of the University of California.
34 */
35
36 /*
37 * svc_cots.c
38 * Server side for connection-oriented RPC in the kernel.
39 *
40 */
41
42 #include <sys/param.h>
43 #include <sys/types.h>
44 #include <sys/sysmacros.h>
45 #include <sys/file.h>
697
698 cd = (cots_data_t *)clone_xprt->xp_p2buf;
699 if ((mp = cd->cd_mp) != NULL) {
700 XDR_DESTROY(&clone_xprt->xp_xdrout);
701 cd->cd_mp = (mblk_t *)NULL;
702 freemsg(mp);
703 }
704 }
705
706 /*
707 * the dup cacheing routines below provide a cache of non-failure
708 * transaction id's. rpc service routines can use this to detect
709 * retransmissions and re-send a non-failure response.
710 */
711
712 /*
713 * MAXDUPREQS is the number of cached items. It should be adjusted
714 * to the service load so that there is likely to be a response entry
715 * when the first retransmission comes in.
716 */
717 #define MAXDUPREQS 8192
718
719 /*
720 * This should be appropriately scaled to MAXDUPREQS.
721 */
722 #define DRHASHSZ 2053
723
724 #if ((DRHASHSZ & (DRHASHSZ - 1)) == 0)
725 #define XIDHASH(xid) ((xid) & (DRHASHSZ - 1))
726 #else
727 #define XIDHASH(xid) ((xid) % DRHASHSZ)
728 #endif
729 #define DRHASH(dr) XIDHASH((dr)->dr_xid)
730 #define REQTOXID(req) ((req)->rq_xprt->xp_xid)
731
732 static int cotsndupreqs = 0;
733 int cotsmaxdupreqs = MAXDUPREQS;
734 static kmutex_t cotsdupreq_lock;
735 static struct dupreq *cotsdrhashtbl[DRHASHSZ];
736 static int cotsdrhashstat[DRHASHSZ];
737
738 static void unhash(struct dupreq *);
739
740 /*
741 * cotsdrmru points to the head of a circular linked list in lru order.
742 * cotsdrmru->dr_next == drlru
|