1479
1480 /*
1481 * Init the stable storage.
1482 */
1483 rfs4_ss_init(nsrv4);
1484 }
1485
1486 /*
1487 * Used at server shutdown to cleanup all of NFSv4 server's zone structures
1488 * and state.
1489 */
1490 void
1491 rfs4_state_zone_fini()
1492 {
1493 rfs4_database_t *dbp;
1494 nfs4_srv_t *nsrv4;
1495 nsrv4 = nfs4_get_srv();
1496
1497 rfs4_set_deleg_policy(nsrv4, SRV_NEVER_DELEGATE);
1498
1499 mutex_enter(&nsrv4->state_lock);
1500
1501 if (nsrv4->nfs4_server_state == NULL) {
1502 mutex_exit(&nsrv4->state_lock);
1503 return;
1504 }
1505
1506 /* destroy server instances and current instance ptr */
1507 rfs4_servinst_destroy_all(nsrv4);
1508
1509 /* reset the "first NFSv4 request" status */
1510 nsrv4->seen_first_compound = 0;
1511
1512 dbp = nsrv4->nfs4_server_state;
1513 nsrv4->nfs4_server_state = NULL;
1514
1515 rw_destroy(&nsrv4->rfs4_findclient_lock);
1516
1517 /* First stop all of the reaper threads in the database */
1518 rfs4_database_shutdown(dbp);
1519 /*
1520 * XXX workaround
1521 * Skip destrying the state database yet just in case there
1522 * are unfinished operations depending on it.
1523 */
1524 /* Now destroy/release the database tables */
1525 /* rfs4_database_destroy(dbp); */
1526
1527 /* Reset the cache timers for next time */
1528 nsrv4->rfs4_client_cache_time = 0;
1529 nsrv4->rfs4_openowner_cache_time = 0;
1530 nsrv4->rfs4_state_cache_time = 0;
1531 nsrv4->rfs4_lo_state_cache_time = 0;
1532 nsrv4->rfs4_lockowner_cache_time = 0;
1533 nsrv4->rfs4_file_cache_time = 0;
1534 nsrv4->rfs4_deleg_state_cache_time = 0;
1535
1536 mutex_exit(&nsrv4->state_lock);
1537
1538 /* clean up any dangling stable storage structures */
1539 rfs4_ss_fini(nsrv4);
1540 }
1541
1542 typedef union {
1543 struct {
1544 uint32_t start_time;
1545 uint32_t c_id;
1546 } impl_id;
1547 clientid4 id4;
1548 } cid;
1549
1550 static int foreign_stateid(stateid_t *id);
1551 static int foreign_clientid(cid *cidp);
1552 static void embed_nodeid(cid *cidp);
1553
1554 typedef union {
1555 struct {
1556 uint32_t c_id;
1557 uint32_t gen_num;
1558 } cv_impl;
1559 verifier4 confirm_verf;
4106 * thread in the global zone for NGZ data structures, so we
4107 * CANNOT use zone_getspecific anywhere in this code path.
4108 */
4109 void
4110 rfs4_clean_state_exi(nfs_export_t *ne, struct exportinfo *exi)
4111 {
4112 nfs_globals_t *ng;
4113 nfs4_srv_t *nsrv4;
4114
4115 ng = ne->ne_globals;
4116 ASSERT(ng->nfs_zoneid == exi->exi_zoneid);
4117 nsrv4 = ng->nfs4_srv;
4118
4119 mutex_enter(&nsrv4->state_lock);
4120
4121 if (nsrv4->nfs4_server_state == NULL) {
4122 mutex_exit(&nsrv4->state_lock);
4123 return;
4124 }
4125
4126 /* CSTYLED */
4127 rfs4_dbe_walk(nsrv4->rfs4_lo_state_tab, rfs4_lo_state_walk_callout, exi);
4128 rfs4_dbe_walk(nsrv4->rfs4_state_tab, rfs4_state_walk_callout, exi);
4129 /* CSTYLED */
4130 rfs4_dbe_walk(nsrv4->rfs4_deleg_state_tab, rfs4_deleg_state_walk_callout, exi);
4131 rfs4_dbe_walk(nsrv4->rfs4_file_tab, rfs4_file_walk_callout, exi);
4132
4133 mutex_exit(&nsrv4->state_lock);
4134 }
|
1479
1480 /*
1481 * Init the stable storage.
1482 */
1483 rfs4_ss_init(nsrv4);
1484 }
1485
1486 /*
1487 * Used at server shutdown to cleanup all of NFSv4 server's zone structures
1488 * and state.
1489 */
1490 void
1491 rfs4_state_zone_fini()
1492 {
1493 rfs4_database_t *dbp;
1494 nfs4_srv_t *nsrv4;
1495 nsrv4 = nfs4_get_srv();
1496
1497 rfs4_set_deleg_policy(nsrv4, SRV_NEVER_DELEGATE);
1498
1499 /*
1500 * Clean up any dangling stable storage structures BEFORE calling
1501 * rfs4_servinst_destroy_all() so there are no dangling structures
1502 * (i.e. the srvinsts are all cleared of danglers BEFORE they get
1503 * freed).
1504 */
1505 rfs4_ss_fini(nsrv4);
1506
1507 mutex_enter(&nsrv4->state_lock);
1508
1509 if (nsrv4->nfs4_server_state == NULL) {
1510 mutex_exit(&nsrv4->state_lock);
1511 return;
1512 }
1513
1514 /* destroy server instances and current instance ptr */
1515 rfs4_servinst_destroy_all(nsrv4);
1516
1517 /* reset the "first NFSv4 request" status */
1518 nsrv4->seen_first_compound = 0;
1519
1520 dbp = nsrv4->nfs4_server_state;
1521 nsrv4->nfs4_server_state = NULL;
1522
1523 rw_destroy(&nsrv4->rfs4_findclient_lock);
1524
1525 /* First stop all of the reaper threads in the database */
1526 rfs4_database_shutdown(dbp);
1527 /*
1528 * WARNING: There may be consumers of the rfs4 database still
1529 * active as we destroy these. IF that's the case, consider putting
1530 * some of their _zone_fini()-like functions into the zsd key as
1531 * ~~SHUTDOWN~~ functions instead of ~~DESTROY~~ functions. We can
1532 * maintain some ordering guarantees better that way.
1533 */
1534 /* Now destroy/release the database tables */
1535 rfs4_database_destroy(dbp);
1536
1537 /* Reset the cache timers for next time */
1538 nsrv4->rfs4_client_cache_time = 0;
1539 nsrv4->rfs4_openowner_cache_time = 0;
1540 nsrv4->rfs4_state_cache_time = 0;
1541 nsrv4->rfs4_lo_state_cache_time = 0;
1542 nsrv4->rfs4_lockowner_cache_time = 0;
1543 nsrv4->rfs4_file_cache_time = 0;
1544 nsrv4->rfs4_deleg_state_cache_time = 0;
1545
1546 mutex_exit(&nsrv4->state_lock);
1547 }
1548
1549 typedef union {
1550 struct {
1551 uint32_t start_time;
1552 uint32_t c_id;
1553 } impl_id;
1554 clientid4 id4;
1555 } cid;
1556
1557 static int foreign_stateid(stateid_t *id);
1558 static int foreign_clientid(cid *cidp);
1559 static void embed_nodeid(cid *cidp);
1560
1561 typedef union {
1562 struct {
1563 uint32_t c_id;
1564 uint32_t gen_num;
1565 } cv_impl;
1566 verifier4 confirm_verf;
4113 * thread in the global zone for NGZ data structures, so we
4114 * CANNOT use zone_getspecific anywhere in this code path.
4115 */
4116 void
4117 rfs4_clean_state_exi(nfs_export_t *ne, struct exportinfo *exi)
4118 {
4119 nfs_globals_t *ng;
4120 nfs4_srv_t *nsrv4;
4121
4122 ng = ne->ne_globals;
4123 ASSERT(ng->nfs_zoneid == exi->exi_zoneid);
4124 nsrv4 = ng->nfs4_srv;
4125
4126 mutex_enter(&nsrv4->state_lock);
4127
4128 if (nsrv4->nfs4_server_state == NULL) {
4129 mutex_exit(&nsrv4->state_lock);
4130 return;
4131 }
4132
4133 rfs4_dbe_walk(nsrv4->rfs4_lo_state_tab,
4134 rfs4_lo_state_walk_callout, exi);
4135 rfs4_dbe_walk(nsrv4->rfs4_state_tab, rfs4_state_walk_callout, exi);
4136 rfs4_dbe_walk(nsrv4->rfs4_deleg_state_tab,
4137 rfs4_deleg_state_walk_callout, exi);
4138 rfs4_dbe_walk(nsrv4->rfs4_file_tab, rfs4_file_walk_callout, exi);
4139
4140 mutex_exit(&nsrv4->state_lock);
4141 }
|