Print this page
Fix NFS design problems re. multiple zone keys
Make NFS server zone-specific data all have the same lifetime
Fix rfs4_clean_state_exi
Fix exi_cache_reclaim
Fix mistakes in zone keys work
More fixes re. exi_zoneid and exi_tree
(danmcd -> Keep some ASSERT()s around for readability.)
@@ -151,11 +151,10 @@
*
*/
#define DIRENT64_TO_DIRCOUNT(dp) \
(3 * BYTES_PER_XDR_UNIT + DIRENT64_NAMELEN((dp)->d_reclen))
-zone_key_t rfs4_zone_key;
static sysid_t lockt_sysid; /* dummy sysid for all LOCKT calls */
u_longlong_t nfs4_srv_caller_id;
uint_t nfs4_srv_vkey = 0;
@@ -499,14 +498,22 @@
VOPNAME_SETSECATTR, { .femop_setsecattr = deleg_wr_setsecattr },
VOPNAME_VNEVENT, { .femop_vnevent = deleg_wr_vnevent },
NULL, NULL
};
-/* ARGSUSED */
-static void *
-rfs4_zone_init(zoneid_t zoneid)
+nfs4_srv_t *
+nfs4_get_srv(void)
{
+ nfs_globals_t *ng = zone_getspecific(nfssrv_zone_key, curzone);
+ nfs4_srv_t *srv = ng->nfs4_srv;
+ ASSERT(srv != NULL);
+ return (srv);
+}
+
+void
+rfs4_srv_zone_init(nfs_globals_t *ng)
+{
nfs4_srv_t *nsrv4;
timespec32_t verf;
nsrv4 = kmem_zalloc(sizeof (*nsrv4), KM_SLEEP);
@@ -547,19 +554,20 @@
mutex_init(&nsrv4->deleg_lock, NULL, MUTEX_DEFAULT, NULL);
mutex_init(&nsrv4->state_lock, NULL, MUTEX_DEFAULT, NULL);
mutex_init(&nsrv4->servinst_lock, NULL, MUTEX_DEFAULT, NULL);
rw_init(&nsrv4->deleg_policy_lock, NULL, RW_DEFAULT, NULL);
- return (nsrv4);
+ ng->nfs4_srv = nsrv4;
}
-/* ARGSUSED */
-static void
-rfs4_zone_fini(zoneid_t zoneid, void *data)
+void
+rfs4_srv_zone_fini(nfs_globals_t *ng)
{
- nfs4_srv_t *nsrv4 = data;
+ nfs4_srv_t *nsrv4 = ng->nfs4_srv;
+ ng->nfs4_srv = NULL;
+
mutex_destroy(&nsrv4->deleg_lock);
mutex_destroy(&nsrv4->state_lock);
mutex_destroy(&nsrv4->servinst_lock);
rw_destroy(&nsrv4->deleg_policy_lock);
@@ -569,15 +577,12 @@
void
rfs4_srvrinit(void)
{
extern void rfs4_attr_init();
- zone_key_create(&rfs4_zone_key, rfs4_zone_init, NULL, rfs4_zone_fini);
-
rfs4_attr_init();
-
if (fem_create("deleg_rdops", nfs4_rd_deleg_tmpl, &deleg_rdops) != 0) {
rfs4_disable_delegation();
} else if (fem_create("deleg_wrops", nfs4_wr_deleg_tmpl,
&deleg_wrops) != 0) {
rfs4_disable_delegation();
@@ -600,19 +605,17 @@
rfs4_state_g_fini();
fem_free(deleg_rdops);
fem_free(deleg_wrops);
-
- (void) zone_key_delete(rfs4_zone_key);
}
void
rfs4_do_server_start(int server_upordown,
int srv_delegation, int cluster_booted)
{
- nfs4_srv_t *nsrv4 = zone_getspecific(rfs4_zone_key, curzone);
+ nfs4_srv_t *nsrv4 = nfs4_get_srv();
/* Is this a warm start? */
if (server_upordown == NFS_SERVER_QUIESCED) {
cmn_err(CE_NOTE, "nfs4_srv: "
"server was previously quiesced; "
@@ -1515,11 +1518,11 @@
if (error) {
*cs->statusp = resp->status = puterrno4(error);
goto out;
}
- nsrv4 = zone_getspecific(rfs4_zone_key, curzone);
+ nsrv4 = nfs4_get_srv();
*cs->statusp = resp->status = NFS4_OK;
resp->writeverf = nsrv4->write4verf;
out:
DTRACE_NFSV4_2(op__commit__done, struct compound_state *, cs,
COMMIT4res *, resp);
@@ -5662,11 +5665,11 @@
if (MANDLOCK(vp, bva.va_mode)) {
*cs->statusp = resp->status = NFS4ERR_ACCESS;
goto out;
}
- nsrv4 = zone_getspecific(rfs4_zone_key, curzone);
+ nsrv4 = nfs4_get_srv();
if (args->data_len == 0) {
*cs->statusp = resp->status = NFS4_OK;
resp->count = 0;
resp->committed = args->stable;
resp->writeverf = nsrv4->write4verf;
@@ -5842,11 +5845,11 @@
resp->array_len = args->array_len;
resp->array = kmem_zalloc(args->array_len * sizeof (nfs_resop4),
KM_SLEEP);
cs.basecr = cr;
- nsrv4 = zone_getspecific(rfs4_zone_key, curzone);
+ nsrv4 = nfs4_get_srv();
DTRACE_NFSV4_2(compound__start, struct compound_state *, &cs,
COMPOUND4args *, args);
/*
@@ -6654,11 +6657,11 @@
/*
* We are writing over an existing file.
* Check to see if we need to recall a delegation.
*/
- nsrv4 = zone_getspecific(rfs4_zone_key, curzone);
+ nsrv4 = nfs4_get_srv();
rfs4_hold_deleg_policy(nsrv4);
if ((fp = rfs4_findfile(vp, NULL, &create)) != NULL) {
if (rfs4_check_delegated_byfp(FWRITE, fp,
(reqsize == 0), FALSE, FALSE, &clientid)) {
rfs4_file_rele(fp);
@@ -8231,11 +8234,11 @@
DTRACE_NFSV4_2(op__setclientid__confirm__start,
struct compound_state *, cs,
SETCLIENTID_CONFIRM4args *, args);
- nsrv4 = zone_getspecific(rfs4_zone_key, curzone);
+ nsrv4 = nfs4_get_srv();
*cs->statusp = res->status = NFS4_OK;
cp = rfs4_findclient_by_id(args->clientid, TRUE);
if (cp == NULL) {