fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * external variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * global data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * local variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * local functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_init:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create the cache data initially, including to invoke individual
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * functions for creating the hash tables for object storage and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * discovery domain membership matrix.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 0: no error; 1: otherwise.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocate global cache memory.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initialize global cache rwlock.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * inintialize global cache functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_destroy:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * destroy the cache data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do nothing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_lock:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * grab the lock on the cache data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode - the read/write mode of the lock.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_unlock:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * release the lock on the cache data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if the cache was locked for writing, a synchronization between
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the cache and persistent data store needs to be performed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode - the read/write mode which the cache data was locked for.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ec - 0: commit the cache update; otherwise retreat it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* sync between cache and data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* rest the cache update flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_lock_read:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * grab the read lock on the cache.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_lock_write:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * grab the write lock on the cache.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_unlock_sync:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * synchronize the cache with persistent data store and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * release the lock.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ec - 0: commit the cache update; otherwise retreat it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_unlock_nosync:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * release the lock, no need to sync the data between cache and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if the cache has been updated, do not call this function, call
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_unlock_sync() with non-zero error code to indicate the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sync action.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_get_htab:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the hash table for individual type of object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type - the object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the hash table.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_get_matrix:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the membership matrix for a discovery domain or a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * discovery domain set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type - the discovery domain or discovery domain set object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the matrix.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_lookup:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * invoke the hash table lookup for looking up a specific object and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * perform the callback function on the object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lcp - the object lookup control data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid_p - the pointer of object UID for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * callback - the callback function for the object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int (*callback)(void *, void *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (lcp->op[0] == OP_INTEGER) ? lcp->data[0].ui : 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_lookup:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * invoke the hash table lookup for looking up a specific object,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the callback function is going to change the key of the object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lcp - the object lookup control data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid_p - the pointer of object UID for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * callback - the callback function for the object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int (*callback)(void *, void *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (lcp->op[0] == OP_INTEGER) ? lcp->data[0].ui : 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_add:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * invoke hash table add to add an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the object being added.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flag - 0: a real object;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * otherwise an association object for discovery domain membership.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid_p - the pointer of object UID for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * update_p - the pointer of flag (update object or newly register)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (htab_add(imc->t[obj->type], obj, flag, uid_p, update_p));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_remove:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * invoke hash table remove to remove an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lcp - the lookup control data for the object being removed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flag - 0: a real object;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * otherwise an association object for discovery domain membership.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the removed object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (lcp->op[0] == OP_INTEGER) ? lcp->data[0].ui : 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache_dump_htab:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dump the hash table for debugging purpose.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type - the object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************