diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2016-07-18 12:01:23 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2016-07-18 12:01:23 +0000 |
commit | 337d9c09c4df5f2c9df3f52c11a8f432e7cfaadc (patch) | |
tree | d6163e4a00277d204a605ecedd1d3484afe1fec1 | |
parent | 862fc303a41b09aea047548a1d6e4482d294982e (diff) | |
parent | d88e84ff401847bce26e4c3203cd18c72c77db33 (diff) | |
download | illumos-joyent-337d9c09c4df5f2c9df3f52c11a8f432e7cfaadc.tar.gz |
[illumos-gate merge]
commit d88e84ff401847bce26e4c3203cd18c72c77db33
7126 NSS_XbyY_FINI has too much logic for a function-like macro
commit 8ee802cce77385ce86e5fe8520cee28ac9fd4669
6458 nfsauth_cache_get() deadlock with kmem reap thread
-rw-r--r-- | usr/src/head/nss_dbdefs.h | 5 | ||||
-rw-r--r-- | usr/src/lib/libc/port/gen/nss_common.c | 54 | ||||
-rw-r--r-- | usr/src/lib/libc/port/mapfile-vers | 1 | ||||
-rw-r--r-- | usr/src/uts/common/fs/nfs/nfs_auth.c | 19 |
4 files changed, 47 insertions, 32 deletions
diff --git a/usr/src/head/nss_dbdefs.h b/usr/src/head/nss_dbdefs.h index 7608e10648..458715632c 100644 --- a/usr/src/head/nss_dbdefs.h +++ b/usr/src/head/nss_dbdefs.h @@ -669,14 +669,13 @@ typedef struct { (str)->h_errno = 0, \ (str)->erange = 0) -#define NSS_XbyY_FINI(str) (\ - (str)->returnval == 0 && (str)->erange && (errno = ERANGE), \ - (str)->returnval) +#define NSS_XbyY_FINI(str) _nss_XbyY_fini(str) #define NSS_PACKED_CRED_CHECK(buf, ruid, euid) (\ ((nss_pheader_t *)(buf))->p_ruid == (ruid) && \ ((nss_pheader_t *)(buf))->p_euid == (euid)) +extern void *_nss_XbyY_fini(nss_XbyY_args_t *); extern char **_nss_netdb_aliases(const char *, int, char *, int); extern nss_status_t nss_default_key2str(void *, size_t, nss_XbyY_args_t *, const char *, int, size_t *); diff --git a/usr/src/lib/libc/port/gen/nss_common.c b/usr/src/lib/libc/port/gen/nss_common.c index 1f3f006372..20740d73c7 100644 --- a/usr/src/lib/libc/port/gen/nss_common.c +++ b/usr/src/lib/libc/port/gen/nss_common.c @@ -1020,24 +1020,20 @@ _nss_status_vec(void) } static void -output_loop_diag_a( - int n, - char *dbase, - struct __nsw_lookup_v1 *lkp) - +output_loop_diag_a(int n, + char *dbase, + struct __nsw_lookup_v1 *lkp) { (void) fprintf(__nss_debug_file, - "NSS_retry(%d): '%s': trying '%s' ... ", - n, dbase, lkp->service_name); + "NSS_retry(%d): '%s': trying '%s' ... ", + n, dbase, lkp->service_name); (void) fflush(__nss_debug_file); } static void -output_loop_diag_b( - nss_status_t res, - struct __nsw_lookup_v1 *lkp) - +output_loop_diag_b(nss_status_t res, + struct __nsw_lookup_v1 *lkp) { (void) fprintf(__nss_debug_file, "result="); switch (res) { @@ -1072,7 +1068,7 @@ output_loop_diag_b( break; case __NSW_TRYAGAIN_NTIMES: (void) fprintf(__nss_debug_file, "TRYAGAIN_NTIMES (N=%d)", - lkp->max_retries); + lkp->max_retries); break; case __NSW_TRYAGAIN_PAUSED: (void) fprintf(__nss_debug_file, "TRYAGAIN_PAUSED"); @@ -1150,7 +1146,7 @@ nss_delete(nss_db_root_t *rootp) nss_status_t nss_search(nss_db_root_t *rootp, nss_db_initf_t initf, int search_fnum, - void *search_args) + void *search_args) { nss_status_t res = NSS_UNAVAIL; struct nss_db_state *s; @@ -1310,7 +1306,7 @@ nss_setent(nss_db_root_t *rootp, nss_db_initf_t initf, nss_getent_t *contextpp) nss_status_t nss_getent(nss_db_root_t *rootp, nss_db_initf_t initf, nss_getent_t *contextpp, - void *args) + void *args) { nss_status_t status; @@ -1364,7 +1360,7 @@ end_iter_u(nss_db_root_t *rootp, struct nss_getent_context *contextp) static void nss_setent_u(nss_db_root_t *rootp, nss_db_initf_t initf, - nss_getent_t *contextpp) + nss_getent_t *contextpp) { nss_status_t status; struct nss_db_state *s; @@ -1449,7 +1445,7 @@ nss_setent_u(nss_db_root_t *rootp, nss_db_initf_t initf, static nss_status_t nss_getent_u(nss_db_root_t *rootp, nss_db_initf_t initf, - nss_getent_t *contextpp, void *args) + nss_getent_t *contextpp, void *args) { nss_status_t status; struct nss_db_state *s; @@ -1533,7 +1529,7 @@ nss_getent_u(nss_db_root_t *rootp, nss_db_initf_t initf, /*ARGSUSED*/ static void nss_endent_u(nss_db_root_t *rootp, nss_db_initf_t initf, - nss_getent_t *contextpp) + nss_getent_t *contextpp) { nss_status_t status; struct nss_getent_context *contextp; @@ -1654,7 +1650,7 @@ nss_pack_dbd(void *buffer, size_t bufsize, nss_db_params_t *p, size_t *poff) /*ARGSUSED*/ nss_status_t nss_pack(void *buffer, size_t bufsize, nss_db_root_t *rootp, - nss_db_initf_t initf, int search_fnum, void *search_args) + nss_db_initf_t initf, int search_fnum, void *search_args) { nss_pheader_t *pbuf = (nss_pheader_t *)buffer; nss_XbyY_args_t *in = (nss_XbyY_args_t *)search_args; @@ -1762,7 +1758,7 @@ nss_pack(void *buffer, size_t bufsize, nss_db_root_t *rootp, /*ARGSUSED*/ nss_status_t nss_pack_ent(void *buffer, size_t bufsize, nss_db_root_t *rootp, - nss_db_initf_t initf, nss_getent_t *contextpp) + nss_db_initf_t initf, nss_getent_t *contextpp) { nss_pheader_t *pbuf = (nss_pheader_t *)buffer; struct nss_getent_context *contextp = contextpp->ctx; @@ -1836,7 +1832,7 @@ nss_pack_ent(void *buffer, size_t bufsize, nss_db_root_t *rootp, /*ARGSUSED*/ nss_status_t nss_unpack(void *buffer, size_t bufsize, nss_db_root_t *rootp, - nss_db_initf_t initf, int search_fnum, void *search_args) + nss_db_initf_t initf, int search_fnum, void *search_args) { nss_pheader_t *pbuf = (nss_pheader_t *)buffer; nss_XbyY_args_t *in = (nss_XbyY_args_t *)search_args; @@ -1937,7 +1933,7 @@ nss_unpack(void *buffer, size_t bufsize, nss_db_root_t *rootp, /*ARGSUSED*/ nss_status_t nss_unpack_ent(void *buffer, size_t bufsize, nss_db_root_t *rootp, - nss_db_initf_t initf, nss_getent_t *contextpp, void *args) + nss_db_initf_t initf, nss_getent_t *contextpp, void *args) { nss_pheader_t *pbuf = (nss_pheader_t *)buffer; nss_XbyY_args_t *in = (nss_XbyY_args_t *)args; @@ -2009,7 +2005,7 @@ nss_unpack_ent(void *buffer, size_t bufsize, nss_db_root_t *rootp, nss_status_t _nsc_search(nss_db_root_t *rootp, nss_db_initf_t initf, int search_fnum, - void *search_args) + void *search_args) { nss_pheader_t *pbuf; void *doorptr = NULL; @@ -2084,7 +2080,7 @@ _nsc_search(nss_db_root_t *rootp, nss_db_initf_t initf, int search_fnum, */ nss_status_t _nsc_setent_u(nss_db_root_t *rootp, nss_db_initf_t initf, - nss_getent_t *contextpp) + nss_getent_t *contextpp) { nss_status_t status = NSS_TRYLOCAL; struct nss_getent_context *contextp = contextpp->ctx; @@ -2161,7 +2157,7 @@ _nsc_setent_u(nss_db_root_t *rootp, nss_db_initf_t initf, nss_status_t _nsc_getent_u(nss_db_root_t *rootp, nss_db_initf_t initf, - nss_getent_t *contextpp, void *args) + nss_getent_t *contextpp, void *args) { nss_status_t status = NSS_TRYLOCAL; struct nss_getent_context *contextp = contextpp->ctx; @@ -2228,7 +2224,7 @@ _nsc_getent_u(nss_db_root_t *rootp, nss_db_initf_t initf, nss_status_t _nsc_endent_u(nss_db_root_t *rootp, nss_db_initf_t initf, - nss_getent_t *contextpp) + nss_getent_t *contextpp) { nss_status_t status = NSS_TRYLOCAL; struct nss_getent_context *contextp = contextpp->ctx; @@ -2298,3 +2294,11 @@ _nss_get_bufsizes(int arg) } return (__nss_buflen_default); } + +void * +_nss_XbyY_fini(nss_XbyY_args_t *args) +{ + if ((args->returnval == NULL) && (args->erange != 0)) + errno = ERANGE; + return (args->returnval); +} diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers index c278c6a8ee..98efe9ed72 100644 --- a/usr/src/lib/libc/port/mapfile-vers +++ b/usr/src/lib/libc/port/mapfile-vers @@ -3044,6 +3044,7 @@ $endif nss_search; nss_setent; _nss_XbyY_fgets; + _nss_XbyY_fini; __nsw_extended_action_v1; __nsw_freeconfig_v1; __nsw_getconfig_v1; diff --git a/usr/src/uts/common/fs/nfs/nfs_auth.c b/usr/src/uts/common/fs/nfs/nfs_auth.c index da60a0ccd0..5fa0e6414f 100644 --- a/usr/src/uts/common/fs/nfs/nfs_auth.c +++ b/usr/src/uts/common/fs/nfs/nfs_auth.c @@ -23,6 +23,7 @@ * Copyright 2016 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015 Joyent, Inc. All rights reserved. + * Copyright (c) 2015 by Delphix. All rights reserved. */ #include <sys/param.h> @@ -60,6 +61,8 @@ volatile uint_t nfsauth_cache_hit; volatile uint_t nfsauth_cache_miss; volatile uint_t nfsauth_cache_refresh; volatile uint_t nfsauth_cache_reclaim; +volatile uint_t exi_cache_auth_reclaim_failed; +volatile uint_t exi_cache_clnt_reclaim_failed; /* * The lifetime of an auth cache entry: @@ -1444,10 +1447,8 @@ exi_cache_trim(struct exportinfo *exi) avl_tree_t *tree; for (i = 0; i < AUTH_TABLESIZE; i++) { - tree = exi->exi_cache[i]; stale_time = gethrestime_sec() - NFSAUTH_CACHE_TRIM; - rw_enter(&exi->exi_cache_lock, RW_READER); /* @@ -1455,7 +1456,16 @@ exi_cache_trim(struct exportinfo *exi) * used for NFSAUTH_CACHE_TRIM seconds. */ for (c = avl_first(tree); c != NULL; c = AVL_NEXT(tree, c)) { - rw_enter(&c->authc_lock, RW_WRITER); + /* + * We are being called by the kmem subsystem to reclaim + * memory so don't block if we can't get the lock. + */ + if (rw_tryenter(&c->authc_lock, RW_WRITER) == 0) { + exi_cache_auth_reclaim_failed++; + rw_exit(&exi->exi_cache_lock); + return; + } + for (p = avl_first(&c->authc_tree); p != NULL; p = next) { next = AVL_NEXT(&c->authc_tree, p); @@ -1501,7 +1511,8 @@ exi_cache_trim(struct exportinfo *exi) if (rw_tryupgrade(&exi->exi_cache_lock) == 0) { rw_exit(&exi->exi_cache_lock); - rw_enter(&exi->exi_cache_lock, RW_WRITER); + exi_cache_clnt_reclaim_failed++; + continue; } for (c = avl_first(tree); c != NULL; c = nextc) { |