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) 1989, 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_clts.c
37 * Server side for 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>
730 * because we have not attempted any XDR encoding.
731 * If we do any XDR encoding and we get an error, then SVC_REPLY()
732 * will freemsg(ud->ud_resp);
733 */
734 ASSERT(ud->ud_resp->b_cont->b_cont == NULL);
735 freeb(ud->ud_resp->b_cont);
736 ud->ud_resp->b_cont = NULL;
737 }
738
739 /*
740 * the dup cacheing routines below provide a cache of non-failure
741 * transaction id's. rpc service routines can use this to detect
742 * retransmissions and re-send a non-failure response.
743 */
744
745 /*
746 * MAXDUPREQS is the number of cached items. It should be adjusted
747 * to the service load so that there is likely to be a response entry
748 * when the first retransmission comes in.
749 */
750 #define MAXDUPREQS 1024
751
752 /*
753 * This should be appropriately scaled to MAXDUPREQS.
754 */
755 #define DRHASHSZ 257
756
757 #if ((DRHASHSZ & (DRHASHSZ - 1)) == 0)
758 #define XIDHASH(xid) ((xid) & (DRHASHSZ - 1))
759 #else
760 #define XIDHASH(xid) ((xid) % DRHASHSZ)
761 #endif
762 #define DRHASH(dr) XIDHASH((dr)->dr_xid)
763 #define REQTOXID(req) ((req)->rq_xprt->xp_xid)
764
765 static int ndupreqs = 0;
766 int maxdupreqs = MAXDUPREQS;
767 static kmutex_t dupreq_lock;
768 static struct dupreq *drhashtbl[DRHASHSZ];
769 static int drhashstat[DRHASHSZ];
770
771 static void unhash(struct dupreq *);
772
773 /*
774 * drmru points to the head of a circular linked list in lru order.
775 * drmru->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) 1989, 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_clts.c
38 * Server side for 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>
731 * because we have not attempted any XDR encoding.
732 * If we do any XDR encoding and we get an error, then SVC_REPLY()
733 * will freemsg(ud->ud_resp);
734 */
735 ASSERT(ud->ud_resp->b_cont->b_cont == NULL);
736 freeb(ud->ud_resp->b_cont);
737 ud->ud_resp->b_cont = NULL;
738 }
739
740 /*
741 * the dup cacheing routines below provide a cache of non-failure
742 * transaction id's. rpc service routines can use this to detect
743 * retransmissions and re-send a non-failure response.
744 */
745
746 /*
747 * MAXDUPREQS is the number of cached items. It should be adjusted
748 * to the service load so that there is likely to be a response entry
749 * when the first retransmission comes in.
750 */
751 #define MAXDUPREQS 8192
752
753 /*
754 * This should be appropriately scaled to MAXDUPREQS.
755 */
756 #define DRHASHSZ 2053
757
758 #if ((DRHASHSZ & (DRHASHSZ - 1)) == 0)
759 #define XIDHASH(xid) ((xid) & (DRHASHSZ - 1))
760 #else
761 #define XIDHASH(xid) ((xid) % DRHASHSZ)
762 #endif
763 #define DRHASH(dr) XIDHASH((dr)->dr_xid)
764 #define REQTOXID(req) ((req)->rq_xprt->xp_xid)
765
766 static int ndupreqs = 0;
767 int maxdupreqs = MAXDUPREQS;
768 static kmutex_t dupreq_lock;
769 static struct dupreq *drhashtbl[DRHASHSZ];
770 static int drhashstat[DRHASHSZ];
771
772 static void unhash(struct dupreq *);
773
774 /*
775 * drmru points to the head of a circular linked list in lru order.
776 * drmru->dr_next == drlru
|