Lines Matching defs:table

44  * t_lowat - integer percentage of table entries	/etc/system only
45 * t_hiwat - integer percentage of table entries /etc/system only
46 * t_lreap - integer percentage of table reap time mdb or /etc/system
47 * t_hreap - integer percentage of table reap time mdb or /etc/system
51 time_t t_lreap = 50; /* default to 50% of table's reap interval */
52 time_t t_hreap = 10; /* default to 10% of table's reap interval */
184 rfs4_table_t *table = private;
208 * Each table will be marked as "shutdown" and the reaper threads
216 rfs4_table_t *table;
219 for (table = db->db_tables; table; table = table->dbt_tnext) {
220 mutex_enter(&table->dbt_reaper_cv_lock);
221 table->dbt_reaper_shutdown = TRUE;
222 cv_broadcast(&table->dbt_reaper_wait);
224 mutex_exit(&table->dbt_reaper_cv_lock);
234 * of the table tables are destroyed and then the database itself
260 rfs4_table_t *table;
265 table = kmem_alloc(sizeof (rfs4_table_t), KM_SLEEP);
266 table->dbt_db = db;
267 rw_init(table->dbt_t_lock, NULL, RW_DEFAULT, NULL);
268 mutex_init(table->dbt_lock, NULL, MUTEX_DEFAULT, NULL);
269 mutex_init(&table->dbt_reaper_cv_lock, NULL, MUTEX_DEFAULT, NULL);
270 cv_init(&table->dbt_reaper_wait, NULL, CV_DEFAULT, NULL);
273 table->dbt_name = kmem_alloc(len+1, KM_SLEEP);
275 (void) strcpy(table->dbt_name, tabname);
276 (void) sprintf(cache_name, "%s_entry_cache", table->dbt_name);
277 table->dbt_max_cache_time = max_cache_time;
278 table->dbt_usize = size;
279 table->dbt_len = hashsize;
280 table->dbt_count = 0;
281 table->dbt_idxcnt = 0;
282 table->dbt_ccnt = 0;
283 table->dbt_maxcnt = idxcnt;
284 table->dbt_indices = NULL;
285 table->dbt_id_space = NULL;
286 table->dbt_reaper_shutdown = FALSE;
292 (void) sprintf(id_name, "%s_id_space", table->dbt_name);
293 table->dbt_id_space = id_space_create(id_name, start,
298 table->dbt_id_lwat = (maxentries * t_lowat) / 100;
300 table->dbt_id_hwat = (maxentries * t_hiwat) / 100;
301 table->dbt_id_reap = MIN(rfs4_reap_interval, max_cache_time);
302 table->dbt_maxentries = maxentries;
303 table->dbt_create = create;
304 table->dbt_destroy = destroy;
305 table->dbt_expiry = expiry;
307 table->dbt_mem_cache = kmem_cache_create(cache_name,
313 table,
318 table->dbt_debug = db->db_debug_flags;
321 table->dbt_tnext = db->db_tables;
322 db->db_tables = table;
325 rfs4_start_reaper(table);
327 return (table);
331 rfs4_table_destroy(rfs4_database_t *db, rfs4_table_t *table)
336 ASSERT(table->dbt_count == 0);
339 if (table == db->db_tables)
340 db->db_tables = table->dbt_tnext;
343 if (p->dbt_tnext == table) {
344 p->dbt_tnext = table->dbt_tnext;
345 table->dbt_tnext = NULL;
353 while (table->dbt_indices) {
354 idx = table->dbt_indices;
355 table->dbt_indices = idx->dbi_inext;
359 rw_destroy(table->dbt_t_lock);
360 mutex_destroy(table->dbt_lock);
361 mutex_destroy(&table->dbt_reaper_cv_lock);
362 cv_destroy(&table->dbt_reaper_wait);
364 kmem_free(table->dbt_name, strlen(table->dbt_name) + 1);
365 if (table->dbt_id_space)
366 id_space_destroy(table->dbt_id_space);
367 kmem_cache_destroy(table->dbt_mem_cache);
368 kmem_free(table, sizeof (rfs4_table_t));
372 rfs4_index_create(rfs4_table_t *table, char *keyname,
380 ASSERT(table->dbt_idxcnt < table->dbt_maxcnt);
384 idx->dbi_table = table;
390 idx->dbi_tblidx = table->dbt_idxcnt;
391 table->dbt_idxcnt++;
393 table->dbt_ccnt++;
394 if (table->dbt_ccnt > 1)
397 table->dbt_name);
403 idx->dbi_inext = table->dbt_indices;
404 table->dbt_indices = idx;
405 idx->dbi_buckets = kmem_zalloc(sizeof (rfs4_bucket_t) * table->dbt_len,
427 rfs4_table_t *table = entry->dbe_table;
430 NFS4_DEBUG(table->dbt_debug & DESTROY_DEBUG,
432 (void*)entry, table->dbt_name));
439 for (idx = table->dbt_indices; idx; idx = idx->dbi_inext) {
454 if (table->dbt_destroy)
455 (*table->dbt_destroy)(entry->dbe_data);
457 if (table->dbt_id_space)
458 id_free(table->dbt_id_space, entry->dbe_id);
460 mutex_enter(table->dbt_lock);
461 table->dbt_count--;
462 mutex_exit(table->dbt_lock);
465 kmem_cache_free(table->dbt_mem_cache, entry);
470 rfs4_dbe_create(rfs4_table_t *table, id_t id, rfs4_entry_t data)
475 NFS4_DEBUG(table->dbt_debug & CREATE_DEBUG,
476 (CE_NOTE, "Creating entry in table %s", table->dbt_name));
478 entry = kmem_cache_alloc(table->dbt_mem_cache, KM_SLEEP);
486 if (table->dbt_id_space)
488 entry->dbe_table = table;
490 for (i = 0; i < table->dbt_maxcnt; i++) {
503 entry->dbe_data = (rfs4_entry_t)&entry->dbe_indices[table->dbt_maxcnt];
504 bzero(entry->dbe_data, table->dbt_usize);
507 if (!(*table->dbt_create)(entry->dbe_data, data)) {
508 kmem_cache_free(table->dbt_mem_cache, entry);
512 mutex_enter(table->dbt_lock);
513 table->dbt_count++;
514 mutex_exit(table->dbt_lock);
520 rfs4_dbe_tabreap_adjust(rfs4_table_t *table)
527 * Adjust the table's reap interval based on the
528 * number of id's currently in use. Each table's
531 ASSERT(MUTEX_HELD(&table->dbt_reaper_cv_lock));
532 tabreap = MIN(rfs4_reap_interval, table->dbt_max_cache_time);
534 in_use = table->dbt_count + 1; /* see rfs4_dbe_create */
535 if (in_use >= table->dbt_id_hwat) {
538 } else if (in_use >= table->dbt_id_lwat) {
544 table->dbt_id_reap = reap_int;
546 table->dbt_name, time_t, table->dbt_id_reap);
555 rfs4_table_t *table = idx->dbi_table;
565 NFS4_DEBUG(table->dbt_debug & SEARCH_DEBUG,
566 (CE_NOTE, "Searching for key %p in table %s by %s",
567 key, table->dbt_name, idx->dbi_keyname));
591 NFS4_DEBUG((table->dbt_debug & SEARCH_DEBUG),
592 (CE_NOTE, "Found entry %p for %p in table %s",
593 (void *)l->entry, key, table->dbt_name));
596 id_free(table->dbt_id_space, id);
601 if (!*create || table->dbt_create == NULL || !idx->dbi_createable ||
602 table->dbt_maxentries == table->dbt_count) {
603 NFS4_DEBUG(table->dbt_debug & SEARCH_DEBUG,
605 key, table->dbt_name));
609 id_free(table->dbt_id_space, id);
613 if (table->dbt_id_space && id == -1) {
617 id = id_alloc(table->dbt_id_space);
620 mutex_enter(&table->dbt_reaper_cv_lock);
621 rfs4_dbe_tabreap_adjust(table);
622 mutex_exit(&table->dbt_reaper_cv_lock);
630 NFS4_DEBUG(table->dbt_debug & OTHER_DEBUG,
633 i, (void*)bp, table->dbt_name, idx->dbi_keyname));
641 entry = rfs4_dbe_create(table, id, arg);
645 id_free(table->dbt_id_space, id);
647 NFS4_DEBUG(table->dbt_debug & CREATE_DEBUG,
648 (CE_NOTE, "Constructor for table %s failed",
649 table->dbt_name));
654 * Add one ref for entry into table's hash - only one
664 for (ip = table->dbt_indices; ip; ip = ip->dbi_inext) {
675 table->dbt_debug & SEARCH_DEBUG || table->dbt_debug & CREATE_DEBUG,
676 (CE_NOTE, "Entry %p created for %s = %p in table %s",
677 (void*)entry, idx->dbi_keyname, (void*)key, table->dbt_name));
686 rfs4_table_t *table = rfs4_client_tab;
697 if (code == CB_CODE_CPR_CHKPT || table == NULL) {
701 buckets = table->dbt_indices->dbi_buckets;
711 for (i = 0; i < table->dbt_len; i++) {
723 * Given a table, lock each of the buckets and walk all entries (in
726 * entries in a particular table via the database locking hierarchy.
728 * the specified table.
731 rfs4_dbe_walk(rfs4_table_t *table,
735 rfs4_bucket_t *buckets = table->dbt_indices->dbi_buckets, *bp;
740 NFS4_DEBUG(table->dbt_debug & WALK_DEBUG,
741 (CE_NOTE, "Walking entries in %s", table->dbt_name));
744 for (i = 0; i < table->dbt_len; i++) {
756 NFS4_DEBUG(table->dbt_debug & WALK_DEBUG,
757 (CE_NOTE, "Walking entries complete %s", table->dbt_name));
762 rfs4_dbe_reap(rfs4_table_t *table, time_t cache_time, uint32_t desired)
764 rfs4_index_t *idx = table->dbt_indices;
772 NFS4_DEBUG(table->dbt_debug & REAP_DEBUG,
773 (CE_NOTE, "Reaping %d entries older than %ld seconds in table %s",
774 desired, cache_time, table->dbt_name));
777 for (i = 0; i < table->dbt_len; i++) {
787 * table reference.
793 (table->dbt_reaper_shutdown ||
794 table->dbt_expiry == NULL ||
795 (*table->dbt_expiry)(entry->dbe_data))) {
828 * entries in this table allowing them to be
832 if (table->dbt_reaper_shutdown && bp->dbk_head != NULL)
835 * If this is a table shutdown, keep going until
838 } while (table->dbt_reaper_shutdown && bp->dbk_head != NULL);
840 if (!table->dbt_reaper_shutdown && desired && count >= desired)
844 NFS4_DEBUG(table->dbt_debug & REAP_DEBUG,
845 (CE_NOTE, "Reaped %d entries older than %ld seconds in table %s",
846 count, cache_time, table->dbt_name));
852 rfs4_table_t *table = (rfs4_table_t *)arg;
855 NFS4_DEBUG(table->dbt_debug,
856 (CE_NOTE, "rfs4_reaper_thread starting for %s", table->dbt_name));
858 CALLB_CPR_INIT(&table->dbt_reaper_cpr_info, &table->dbt_reaper_cv_lock,
861 mutex_enter(&table->dbt_reaper_cv_lock);
863 CALLB_CPR_SAFE_BEGIN(&table->dbt_reaper_cpr_info);
864 rc = cv_reltimedwait_sig(&table->dbt_reaper_wait,
865 &table->dbt_reaper_cv_lock,
866 SEC_TO_TICK(table->dbt_id_reap), TR_CLOCK_TICK);
867 CALLB_CPR_SAFE_END(&table->dbt_reaper_cpr_info,
868 &table->dbt_reaper_cv_lock);
869 rfs4_dbe_reap(table, table->dbt_max_cache_time, 0);
870 } while (rc != 0 && table->dbt_reaper_shutdown == FALSE);
872 CALLB_CPR_EXIT(&table->dbt_reaper_cpr_info);
874 NFS4_DEBUG(table->dbt_debug,
875 (CE_NOTE, "rfs4_reaper_thread exiting for %s", table->dbt_name));
877 /* Notify the database shutdown processing that the table is shutdown */
878 mutex_enter(table->dbt_db->db_lock);
879 table->dbt_db->db_shutdown_count--;
880 cv_signal(&table->dbt_db->db_shutdown_wait);
881 mutex_exit(table->dbt_db->db_lock);
885 rfs4_start_reaper(rfs4_table_t *table)
887 if (table->dbt_max_cache_time == 0)
890 (void) thread_create(NULL, 0, reaper_thread, table, 0, &p0, TS_RUN,
898 cmn_err(CE_NOTE, "Entry %p from table %s",