Print this page
5513 KM_NORMALPRI should be documented in kmem_alloc(9f) and kmem_cache_create(9f) man pages
14465 Present KM_NOSLEEP_LAZY as documented interface
Change-Id: I002ec28ddf390650f1fcba1ca94f6abfdb241439


 905         } else {
 906                 addr.buf = NULL;
 907         }
 908 
 909         SVC_GETADDRMASK(req->rq_xprt, SVC_TATTR_ADDRMASK, (void **)&taddrmask);
 910         ASSERT(taddrmask != NULL);
 911         addrmask(&addr, taddrmask);
 912 
 913         acc.authc_addr = addr;
 914 
 915         tree = exi->exi_cache[hash(&addr)];
 916 
 917         rw_enter(&exi->exi_cache_lock, RW_READER);
 918         c = (struct auth_cache_clnt *)avl_find(tree, &acc, NULL);
 919 
 920         if (c == NULL) {
 921                 struct auth_cache_clnt *nc;
 922 
 923                 rw_exit(&exi->exi_cache_lock);
 924 
 925                 nc = kmem_alloc(sizeof (*nc), KM_NOSLEEP | KM_NORMALPRI);
 926                 if (nc == NULL)
 927                         goto retrieve;
 928 
 929                 /*
 930                  * Initialize the new auth_cache_clnt
 931                  */
 932                 nc->authc_addr = addr;
 933                 nc->authc_addr.buf = kmem_alloc(addr.maxlen,
 934                     KM_NOSLEEP | KM_NORMALPRI);
 935                 if (addr.maxlen != 0 && nc->authc_addr.buf == NULL) {
 936                         kmem_free(nc, sizeof (*nc));
 937                         goto retrieve;
 938                 }
 939                 bcopy(addr.buf, nc->authc_addr.buf, addr.len);
 940                 rw_init(&nc->authc_lock, NULL, RW_DEFAULT, NULL);
 941                 avl_create(&nc->authc_tree, nfsauth_cache_compar,
 942                     sizeof (struct auth_cache),
 943                     offsetof(struct auth_cache, auth_link));
 944 
 945                 rw_enter(&exi->exi_cache_lock, RW_WRITER);
 946                 c = (struct auth_cache_clnt *)avl_find(tree, &acc, &where);
 947                 if (c == NULL) {
 948                         avl_insert(tree, nc, where);
 949                         rw_downgrade(&exi->exi_cache_lock);
 950                         c = nc;
 951                 } else {
 952                         rw_downgrade(&exi->exi_cache_lock);
 953 
 954                         avl_destroy(&nc->authc_tree);
 955                         rw_destroy(&nc->authc_lock);
 956                         kmem_free(nc->authc_addr.buf, nc->authc_addr.maxlen);
 957                         kmem_free(nc, sizeof (*nc));
 958                 }
 959         }
 960 
 961         ASSERT(c != NULL);
 962 
 963         rw_enter(&c->authc_lock, RW_READER);
 964 
 965         ac.auth_flavor = flavor;
 966         ac.auth_clnt_cred = cr;
 967 
 968         p = (struct auth_cache *)avl_find(&c->authc_tree, &ac, NULL);
 969 
 970         if (p == NULL) {
 971                 struct auth_cache *np;
 972 
 973                 rw_exit(&c->authc_lock);
 974 
 975                 np = kmem_cache_alloc(exi_cache_handle,
 976                     KM_NOSLEEP | KM_NORMALPRI);
 977                 if (np == NULL) {
 978                         rw_exit(&exi->exi_cache_lock);
 979                         goto retrieve;
 980                 }
 981 
 982                 /*
 983                  * Initialize the new auth_cache
 984                  */
 985                 np->auth_clnt = c;
 986                 np->auth_flavor = flavor;
 987                 np->auth_clnt_cred = crdup(cr);
 988                 np->auth_srv_ngids = 0;
 989                 np->auth_srv_gids = NULL;
 990                 np->auth_time = np->auth_freshness = gethrestime_sec();
 991                 np->auth_state = NFS_AUTH_NEW;
 992                 mutex_init(&np->auth_lock, NULL, MUTEX_DEFAULT, NULL);
 993                 cv_init(&np->auth_cv, NULL, CV_DEFAULT, NULL);
 994 
 995                 rw_enter(&c->authc_lock, RW_WRITER);
 996                 rw_exit(&exi->exi_cache_lock);


1054                     flavor, &addr, &access, cr, &tmpuid, &tmpgid, &tmpngids,
1055                     &tmpgids);
1056 
1057                 p->auth_access = access;
1058                 p->auth_time = p->auth_freshness = gethrestime_sec();
1059 
1060                 if (res == TRUE) {
1061                         if (uid != NULL)
1062                                 *uid = tmpuid;
1063                         if (gid != NULL)
1064                                 *gid = tmpgid;
1065                         if (ngids != NULL && gids != NULL) {
1066                                 *ngids = tmpngids;
1067                                 *gids = tmpgids;
1068 
1069                                 /*
1070                                  * We need a copy of gids for the
1071                                  * auth_cache entry
1072                                  */
1073                                 tmpgids = kmem_alloc(tmpngids * sizeof (gid_t),
1074                                     KM_NOSLEEP | KM_NORMALPRI);
1075                                 if (tmpgids != NULL)
1076                                         bcopy(*gids, tmpgids,
1077                                             tmpngids * sizeof (gid_t));
1078                         }
1079 
1080                         if (tmpgids != NULL || tmpngids == 0) {
1081                                 p->auth_srv_uid = tmpuid;
1082                                 p->auth_srv_gid = tmpgid;
1083                                 p->auth_srv_ngids = tmpngids;
1084                                 p->auth_srv_gids = tmpgids;
1085 
1086                                 state = NFS_AUTH_FRESH;
1087                         }
1088                 }
1089 
1090                 /*
1091                  * Set the auth_state and notify waiters.
1092                  */
1093                 mutex_enter(&p->auth_lock);
1094                 p->auth_state = state;




 905         } else {
 906                 addr.buf = NULL;
 907         }
 908 
 909         SVC_GETADDRMASK(req->rq_xprt, SVC_TATTR_ADDRMASK, (void **)&taddrmask);
 910         ASSERT(taddrmask != NULL);
 911         addrmask(&addr, taddrmask);
 912 
 913         acc.authc_addr = addr;
 914 
 915         tree = exi->exi_cache[hash(&addr)];
 916 
 917         rw_enter(&exi->exi_cache_lock, RW_READER);
 918         c = (struct auth_cache_clnt *)avl_find(tree, &acc, NULL);
 919 
 920         if (c == NULL) {
 921                 struct auth_cache_clnt *nc;
 922 
 923                 rw_exit(&exi->exi_cache_lock);
 924 
 925                 nc = kmem_alloc(sizeof (*nc), KM_NOSLEEP_LAZY);
 926                 if (nc == NULL)
 927                         goto retrieve;
 928 
 929                 /*
 930                  * Initialize the new auth_cache_clnt
 931                  */
 932                 nc->authc_addr = addr;
 933                 nc->authc_addr.buf = kmem_alloc(addr.maxlen, KM_NOSLEEP_LAZY);

 934                 if (addr.maxlen != 0 && nc->authc_addr.buf == NULL) {
 935                         kmem_free(nc, sizeof (*nc));
 936                         goto retrieve;
 937                 }
 938                 bcopy(addr.buf, nc->authc_addr.buf, addr.len);
 939                 rw_init(&nc->authc_lock, NULL, RW_DEFAULT, NULL);
 940                 avl_create(&nc->authc_tree, nfsauth_cache_compar,
 941                     sizeof (struct auth_cache),
 942                     offsetof(struct auth_cache, auth_link));
 943 
 944                 rw_enter(&exi->exi_cache_lock, RW_WRITER);
 945                 c = (struct auth_cache_clnt *)avl_find(tree, &acc, &where);
 946                 if (c == NULL) {
 947                         avl_insert(tree, nc, where);
 948                         rw_downgrade(&exi->exi_cache_lock);
 949                         c = nc;
 950                 } else {
 951                         rw_downgrade(&exi->exi_cache_lock);
 952 
 953                         avl_destroy(&nc->authc_tree);
 954                         rw_destroy(&nc->authc_lock);
 955                         kmem_free(nc->authc_addr.buf, nc->authc_addr.maxlen);
 956                         kmem_free(nc, sizeof (*nc));
 957                 }
 958         }
 959 
 960         ASSERT(c != NULL);
 961 
 962         rw_enter(&c->authc_lock, RW_READER);
 963 
 964         ac.auth_flavor = flavor;
 965         ac.auth_clnt_cred = cr;
 966 
 967         p = (struct auth_cache *)avl_find(&c->authc_tree, &ac, NULL);
 968 
 969         if (p == NULL) {
 970                 struct auth_cache *np;
 971 
 972                 rw_exit(&c->authc_lock);
 973 
 974                 np = kmem_cache_alloc(exi_cache_handle, KM_NOSLEEP_LAZY);

 975                 if (np == NULL) {
 976                         rw_exit(&exi->exi_cache_lock);
 977                         goto retrieve;
 978                 }
 979 
 980                 /*
 981                  * Initialize the new auth_cache
 982                  */
 983                 np->auth_clnt = c;
 984                 np->auth_flavor = flavor;
 985                 np->auth_clnt_cred = crdup(cr);
 986                 np->auth_srv_ngids = 0;
 987                 np->auth_srv_gids = NULL;
 988                 np->auth_time = np->auth_freshness = gethrestime_sec();
 989                 np->auth_state = NFS_AUTH_NEW;
 990                 mutex_init(&np->auth_lock, NULL, MUTEX_DEFAULT, NULL);
 991                 cv_init(&np->auth_cv, NULL, CV_DEFAULT, NULL);
 992 
 993                 rw_enter(&c->authc_lock, RW_WRITER);
 994                 rw_exit(&exi->exi_cache_lock);


1052                     flavor, &addr, &access, cr, &tmpuid, &tmpgid, &tmpngids,
1053                     &tmpgids);
1054 
1055                 p->auth_access = access;
1056                 p->auth_time = p->auth_freshness = gethrestime_sec();
1057 
1058                 if (res == TRUE) {
1059                         if (uid != NULL)
1060                                 *uid = tmpuid;
1061                         if (gid != NULL)
1062                                 *gid = tmpgid;
1063                         if (ngids != NULL && gids != NULL) {
1064                                 *ngids = tmpngids;
1065                                 *gids = tmpgids;
1066 
1067                                 /*
1068                                  * We need a copy of gids for the
1069                                  * auth_cache entry
1070                                  */
1071                                 tmpgids = kmem_alloc(tmpngids * sizeof (gid_t),
1072                                     KM_NOSLEEP_LAZY);
1073                                 if (tmpgids != NULL)
1074                                         bcopy(*gids, tmpgids,
1075                                             tmpngids * sizeof (gid_t));
1076                         }
1077 
1078                         if (tmpgids != NULL || tmpngids == 0) {
1079                                 p->auth_srv_uid = tmpuid;
1080                                 p->auth_srv_gid = tmpgid;
1081                                 p->auth_srv_ngids = tmpngids;
1082                                 p->auth_srv_gids = tmpgids;
1083 
1084                                 state = NFS_AUTH_FRESH;
1085                         }
1086                 }
1087 
1088                 /*
1089                  * Set the auth_state and notify waiters.
1090                  */
1091                 mutex_enter(&p->auth_lock);
1092                 p->auth_state = state;