Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*


 448         kstat_named_t   rcnewcreds;
 449         kstat_named_t   rcbadverfs;
 450         kstat_named_t   rctimers;
 451         kstat_named_t   rccantconn;
 452         kstat_named_t   rcnomem;
 453         kstat_named_t   rcintrs;
 454 } cots_rcstat_tmpl = {
 455         { "calls",      KSTAT_DATA_UINT64 },
 456         { "badcalls",   KSTAT_DATA_UINT64 },
 457         { "badxids",    KSTAT_DATA_UINT64 },
 458         { "timeouts",   KSTAT_DATA_UINT64 },
 459         { "newcreds",   KSTAT_DATA_UINT64 },
 460         { "badverfs",   KSTAT_DATA_UINT64 },
 461         { "timers",     KSTAT_DATA_UINT64 },
 462         { "cantconn",   KSTAT_DATA_UINT64 },
 463         { "nomem",      KSTAT_DATA_UINT64 },
 464         { "interrupts", KSTAT_DATA_UINT64 }
 465 };
 466 
 467 #define COTSRCSTAT_INCR(p, x)   \
 468         atomic_add_64(&(p)->x.value.ui64, 1)
 469 
 470 #define CLNT_MAX_CONNS  1       /* concurrent connections between clnt/srvr */
 471 int clnt_max_conns = CLNT_MAX_CONNS;
 472 
 473 #define CLNT_MIN_TIMEOUT        10      /* seconds to wait after we get a */
 474                                         /* connection reset */
 475 #define CLNT_MIN_CONNTIMEOUT    5       /* seconds to wait for a connection */
 476 
 477 
 478 int clnt_cots_min_tout = CLNT_MIN_TIMEOUT;
 479 int clnt_cots_min_conntout = CLNT_MIN_CONNTIMEOUT;
 480 
 481 /*
 482  * Limit the number of times we will attempt to receive a reply without
 483  * re-sending a response.
 484  */
 485 #define CLNT_MAXRECV_WITHOUT_RETRY      3
 486 uint_t clnt_cots_maxrecv        = CLNT_MAXRECV_WITHOUT_RETRY;
 487 
 488 uint_t *clnt_max_msg_sizep;


2778          */
2779         if (addrfmly == AF_INET || addrfmly == AF_INET6) {
2780                 (void) connmgr_setopt(wq, IPPROTO_TCP, TCP_NODELAY, e, cr);
2781                 if (e->call_status == RPC_XPRTFAILED)
2782                         return (FALSE);
2783         }
2784 
2785         /*
2786          * Since we have a connection, we now need to figure out if
2787          * we need to create a kstat. If x_ksp is not NULL then we
2788          * are reusing a connection and so we do not need to create
2789          * another kstat -- lets just return.
2790          */
2791         if (cm_entry->x_ksp != NULL)
2792                 return (TRUE);
2793 
2794         /*
2795          * We need to increment rpc_kstat_instance atomically to prevent
2796          * two kstats being created with the same instance.
2797          */
2798         kstat_instance = atomic_add_32_nv((uint32_t *)&rpc_kstat_instance, 1);
2799 
2800         if ((cm_entry->x_ksp = kstat_create_zone("unix", kstat_instance,
2801             "rpc_cots_connections", "rpc", KSTAT_TYPE_NAMED,
2802             (uint_t)(sizeof (cm_kstat_xprt_t) / sizeof (kstat_named_t)),
2803             KSTAT_FLAG_VIRTUAL, cm_entry->x_zoneid)) == NULL) {
2804                 return (TRUE);
2805         }
2806 
2807         cm_entry->x_ksp->ks_lock = &connmgr_lock;
2808         cm_entry->x_ksp->ks_private = cm_entry;
2809         cm_entry->x_ksp->ks_data_size = ((INET6_ADDRSTRLEN * sizeof (char))
2810             + sizeof (cm_kstat_template));
2811         cm_entry->x_ksp->ks_data = kmem_alloc(cm_entry->x_ksp->ks_data_size,
2812             KM_SLEEP);
2813         bcopy(&cm_kstat_template, cm_entry->x_ksp->ks_data,
2814             cm_entry->x_ksp->ks_data_size);
2815         ((struct cm_kstat_xprt *)(cm_entry->x_ksp->ks_data))->
2816             x_server.value.str.addr.ptr =
2817             kmem_alloc(INET6_ADDRSTRLEN, KM_SLEEP);
2818 




 448         kstat_named_t   rcnewcreds;
 449         kstat_named_t   rcbadverfs;
 450         kstat_named_t   rctimers;
 451         kstat_named_t   rccantconn;
 452         kstat_named_t   rcnomem;
 453         kstat_named_t   rcintrs;
 454 } cots_rcstat_tmpl = {
 455         { "calls",      KSTAT_DATA_UINT64 },
 456         { "badcalls",   KSTAT_DATA_UINT64 },
 457         { "badxids",    KSTAT_DATA_UINT64 },
 458         { "timeouts",   KSTAT_DATA_UINT64 },
 459         { "newcreds",   KSTAT_DATA_UINT64 },
 460         { "badverfs",   KSTAT_DATA_UINT64 },
 461         { "timers",     KSTAT_DATA_UINT64 },
 462         { "cantconn",   KSTAT_DATA_UINT64 },
 463         { "nomem",      KSTAT_DATA_UINT64 },
 464         { "interrupts", KSTAT_DATA_UINT64 }
 465 };
 466 
 467 #define COTSRCSTAT_INCR(p, x)   \
 468         atomic_inc_64(&(p)->x.value.ui64)
 469 
 470 #define CLNT_MAX_CONNS  1       /* concurrent connections between clnt/srvr */
 471 int clnt_max_conns = CLNT_MAX_CONNS;
 472 
 473 #define CLNT_MIN_TIMEOUT        10      /* seconds to wait after we get a */
 474                                         /* connection reset */
 475 #define CLNT_MIN_CONNTIMEOUT    5       /* seconds to wait for a connection */
 476 
 477 
 478 int clnt_cots_min_tout = CLNT_MIN_TIMEOUT;
 479 int clnt_cots_min_conntout = CLNT_MIN_CONNTIMEOUT;
 480 
 481 /*
 482  * Limit the number of times we will attempt to receive a reply without
 483  * re-sending a response.
 484  */
 485 #define CLNT_MAXRECV_WITHOUT_RETRY      3
 486 uint_t clnt_cots_maxrecv        = CLNT_MAXRECV_WITHOUT_RETRY;
 487 
 488 uint_t *clnt_max_msg_sizep;


2778          */
2779         if (addrfmly == AF_INET || addrfmly == AF_INET6) {
2780                 (void) connmgr_setopt(wq, IPPROTO_TCP, TCP_NODELAY, e, cr);
2781                 if (e->call_status == RPC_XPRTFAILED)
2782                         return (FALSE);
2783         }
2784 
2785         /*
2786          * Since we have a connection, we now need to figure out if
2787          * we need to create a kstat. If x_ksp is not NULL then we
2788          * are reusing a connection and so we do not need to create
2789          * another kstat -- lets just return.
2790          */
2791         if (cm_entry->x_ksp != NULL)
2792                 return (TRUE);
2793 
2794         /*
2795          * We need to increment rpc_kstat_instance atomically to prevent
2796          * two kstats being created with the same instance.
2797          */
2798         kstat_instance = atomic_inc_32_nv((uint32_t *)&rpc_kstat_instance);
2799 
2800         if ((cm_entry->x_ksp = kstat_create_zone("unix", kstat_instance,
2801             "rpc_cots_connections", "rpc", KSTAT_TYPE_NAMED,
2802             (uint_t)(sizeof (cm_kstat_xprt_t) / sizeof (kstat_named_t)),
2803             KSTAT_FLAG_VIRTUAL, cm_entry->x_zoneid)) == NULL) {
2804                 return (TRUE);
2805         }
2806 
2807         cm_entry->x_ksp->ks_lock = &connmgr_lock;
2808         cm_entry->x_ksp->ks_private = cm_entry;
2809         cm_entry->x_ksp->ks_data_size = ((INET6_ADDRSTRLEN * sizeof (char))
2810             + sizeof (cm_kstat_template));
2811         cm_entry->x_ksp->ks_data = kmem_alloc(cm_entry->x_ksp->ks_data_size,
2812             KM_SLEEP);
2813         bcopy(&cm_kstat_template, cm_entry->x_ksp->ks_data,
2814             cm_entry->x_ksp->ks_data_size);
2815         ((struct cm_kstat_xprt *)(cm_entry->x_ksp->ks_data))->
2816             x_server.value.str.addr.ptr =
2817             kmem_alloc(INET6_ADDRSTRLEN, KM_SLEEP);
2818