1*fcf3ce44SJohn Forte /* 2*fcf3ce44SJohn Forte * CDDL HEADER START 3*fcf3ce44SJohn Forte * 4*fcf3ce44SJohn Forte * The contents of this file are subject to the terms of the 5*fcf3ce44SJohn Forte * Common Development and Distribution License (the "License"). 6*fcf3ce44SJohn Forte * You may not use this file except in compliance with the License. 7*fcf3ce44SJohn Forte * 8*fcf3ce44SJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*fcf3ce44SJohn Forte * or http://www.opensolaris.org/os/licensing. 10*fcf3ce44SJohn Forte * See the License for the specific language governing permissions 11*fcf3ce44SJohn Forte * and limitations under the License. 12*fcf3ce44SJohn Forte * 13*fcf3ce44SJohn Forte * When distributing Covered Code, include this CDDL HEADER in each 14*fcf3ce44SJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*fcf3ce44SJohn Forte * If applicable, add the following below this CDDL HEADER, with the 16*fcf3ce44SJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying 17*fcf3ce44SJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner] 18*fcf3ce44SJohn Forte * 19*fcf3ce44SJohn Forte * CDDL HEADER END 20*fcf3ce44SJohn Forte */ 21*fcf3ce44SJohn Forte 22*fcf3ce44SJohn Forte /* 23*fcf3ce44SJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24*fcf3ce44SJohn Forte * Use is subject to license terms. 25*fcf3ce44SJohn Forte */ 26*fcf3ce44SJohn Forte 27*fcf3ce44SJohn Forte #include <stdio.h> 28*fcf3ce44SJohn Forte #include <stdlib.h> 29*fcf3ce44SJohn Forte #include <string.h> 30*fcf3ce44SJohn Forte 31*fcf3ce44SJohn Forte #include "isns_server.h" 32*fcf3ce44SJohn Forte #include "isns_cache.h" 33*fcf3ce44SJohn Forte #include "isns_msgq.h" 34*fcf3ce44SJohn Forte #include "isns_obj.h" 35*fcf3ce44SJohn Forte #include "isns_htab.h" 36*fcf3ce44SJohn Forte 37*fcf3ce44SJohn Forte /* 38*fcf3ce44SJohn Forte * external variables 39*fcf3ce44SJohn Forte */ 40*fcf3ce44SJohn Forte extern msg_queue_t *sys_q; 41*fcf3ce44SJohn Forte 42*fcf3ce44SJohn Forte #ifdef DEBUG 43*fcf3ce44SJohn Forte extern int verbose_lock; 44*fcf3ce44SJohn Forte #endif 45*fcf3ce44SJohn Forte 46*fcf3ce44SJohn Forte /* 47*fcf3ce44SJohn Forte * global data 48*fcf3ce44SJohn Forte */ 49*fcf3ce44SJohn Forte int cache_flag = 0; 50*fcf3ce44SJohn Forte 51*fcf3ce44SJohn Forte /* 52*fcf3ce44SJohn Forte * local variables 53*fcf3ce44SJohn Forte */ 54*fcf3ce44SJohn Forte static cache_t *imc; 55*fcf3ce44SJohn Forte 56*fcf3ce44SJohn Forte /* 57*fcf3ce44SJohn Forte * local functions. 58*fcf3ce44SJohn Forte */ 59*fcf3ce44SJohn Forte 60*fcf3ce44SJohn Forte /* 61*fcf3ce44SJohn Forte * **************************************************************************** 62*fcf3ce44SJohn Forte * cache_init: 63*fcf3ce44SJohn Forte * create the cache data initially, including to invoke individual 64*fcf3ce44SJohn Forte * functions for creating the hash tables for object storage and 65*fcf3ce44SJohn Forte * discovery domain membership matrix. 66*fcf3ce44SJohn Forte * 67*fcf3ce44SJohn Forte * return - 0: no error; 1: otherwise. 68*fcf3ce44SJohn Forte * 69*fcf3ce44SJohn Forte * **************************************************************************** 70*fcf3ce44SJohn Forte */ 71*fcf3ce44SJohn Forte int 72*fcf3ce44SJohn Forte cache_init( 73*fcf3ce44SJohn Forte ) 74*fcf3ce44SJohn Forte { 75*fcf3ce44SJohn Forte /* 76*fcf3ce44SJohn Forte * allocate global cache memory. 77*fcf3ce44SJohn Forte */ 78*fcf3ce44SJohn Forte imc = (cache_t *)calloc(sizeof (cache_t), 1); 79*fcf3ce44SJohn Forte if (imc == NULL || 80*fcf3ce44SJohn Forte obj_tab_init(imc) != 0 || 81*fcf3ce44SJohn Forte dd_matrix_init(imc) != 0) { 82*fcf3ce44SJohn Forte cache_destroy(); 83*fcf3ce44SJohn Forte return (1); /* no memory */ 84*fcf3ce44SJohn Forte } 85*fcf3ce44SJohn Forte 86*fcf3ce44SJohn Forte /* 87*fcf3ce44SJohn Forte * initialize global cache rwlock. 88*fcf3ce44SJohn Forte */ 89*fcf3ce44SJohn Forte (void) rwlock_init(&imc->l, NULL, NULL); 90*fcf3ce44SJohn Forte 91*fcf3ce44SJohn Forte /* 92*fcf3ce44SJohn Forte * inintialize global cache functions. 93*fcf3ce44SJohn Forte */ 94*fcf3ce44SJohn Forte imc->get_hval = obj_hval; 95*fcf3ce44SJohn Forte imc->get_uid = get_obj_uid; 96*fcf3ce44SJohn Forte imc->set_uid = set_obj_uid; 97*fcf3ce44SJohn Forte imc->timestamp = get_timestamp; 98*fcf3ce44SJohn Forte imc->add_hook = add_object; 99*fcf3ce44SJohn Forte imc->replace_hook = replace_object; 100*fcf3ce44SJohn Forte imc->cmp = obj_cmp; 101*fcf3ce44SJohn Forte imc->clone = assoc_clone; 102*fcf3ce44SJohn Forte imc->ddd = update_ddd; 103*fcf3ce44SJohn Forte #ifdef DEBUG 104*fcf3ce44SJohn Forte imc->dump = obj_dump; 105*fcf3ce44SJohn Forte #endif 106*fcf3ce44SJohn Forte 107*fcf3ce44SJohn Forte return (0); 108*fcf3ce44SJohn Forte } 109*fcf3ce44SJohn Forte 110*fcf3ce44SJohn Forte /* 111*fcf3ce44SJohn Forte * **************************************************************************** 112*fcf3ce44SJohn Forte * cache_destroy: 113*fcf3ce44SJohn Forte * destroy the cache data. 114*fcf3ce44SJohn Forte * 115*fcf3ce44SJohn Forte * **************************************************************************** 116*fcf3ce44SJohn Forte */ 117*fcf3ce44SJohn Forte void 118*fcf3ce44SJohn Forte cache_destroy( 119*fcf3ce44SJohn Forte ) 120*fcf3ce44SJohn Forte { 121*fcf3ce44SJohn Forte /* do nothing */ 122*fcf3ce44SJohn Forte } 123*fcf3ce44SJohn Forte 124*fcf3ce44SJohn Forte /* 125*fcf3ce44SJohn Forte * **************************************************************************** 126*fcf3ce44SJohn Forte * cache_lock: 127*fcf3ce44SJohn Forte * grab the lock on the cache data. 128*fcf3ce44SJohn Forte * 129*fcf3ce44SJohn Forte * mode - the read/write mode of the lock. 130*fcf3ce44SJohn Forte * return - error code. 131*fcf3ce44SJohn Forte * 132*fcf3ce44SJohn Forte * **************************************************************************** 133*fcf3ce44SJohn Forte */ 134*fcf3ce44SJohn Forte int 135*fcf3ce44SJohn Forte cache_lock( 136*fcf3ce44SJohn Forte int mode 137*fcf3ce44SJohn Forte ) 138*fcf3ce44SJohn Forte { 139*fcf3ce44SJohn Forte int ret = 0; 140*fcf3ce44SJohn Forte 141*fcf3ce44SJohn Forte switch (mode) { 142*fcf3ce44SJohn Forte case CACHE_WRITE: 143*fcf3ce44SJohn Forte ret = rw_wrlock(&imc->l); 144*fcf3ce44SJohn Forte #ifdef DEBUG 145*fcf3ce44SJohn Forte if (verbose_lock) { 146*fcf3ce44SJohn Forte printf("cache locked for writing.\n"); 147*fcf3ce44SJohn Forte } 148*fcf3ce44SJohn Forte #endif 149*fcf3ce44SJohn Forte break; 150*fcf3ce44SJohn Forte case CACHE_READ: 151*fcf3ce44SJohn Forte ret = rw_rdlock(&imc->l); 152*fcf3ce44SJohn Forte #ifdef DEBUG 153*fcf3ce44SJohn Forte if (verbose_lock) { 154*fcf3ce44SJohn Forte printf("cache locked for reading.\n"); 155*fcf3ce44SJohn Forte } 156*fcf3ce44SJohn Forte #endif 157*fcf3ce44SJohn Forte break; 158*fcf3ce44SJohn Forte case CACHE_TRY_READ: 159*fcf3ce44SJohn Forte ret = rw_tryrdlock(&imc->l); 160*fcf3ce44SJohn Forte #ifdef DEBUG 161*fcf3ce44SJohn Forte if (verbose_lock) { 162*fcf3ce44SJohn Forte if (ret == 0) { 163*fcf3ce44SJohn Forte printf("cache locked for reading.\n"); 164*fcf3ce44SJohn Forte } else { 165*fcf3ce44SJohn Forte printf("cache locked for reading failed.\n"); 166*fcf3ce44SJohn Forte } 167*fcf3ce44SJohn Forte } 168*fcf3ce44SJohn Forte #endif 169*fcf3ce44SJohn Forte break; 170*fcf3ce44SJohn Forte default: 171*fcf3ce44SJohn Forte break; 172*fcf3ce44SJohn Forte } 173*fcf3ce44SJohn Forte 174*fcf3ce44SJohn Forte return (ret); 175*fcf3ce44SJohn Forte } 176*fcf3ce44SJohn Forte 177*fcf3ce44SJohn Forte /* 178*fcf3ce44SJohn Forte * **************************************************************************** 179*fcf3ce44SJohn Forte * cache_unlock: 180*fcf3ce44SJohn Forte * release the lock on the cache data. 181*fcf3ce44SJohn Forte * if the cache was locked for writing, a synchronization between 182*fcf3ce44SJohn Forte * the cache and persistent data store needs to be performed. 183*fcf3ce44SJohn Forte * 184*fcf3ce44SJohn Forte * mode - the read/write mode which the cache data was locked for. 185*fcf3ce44SJohn Forte * ec - 0: commit the cache update; otherwise retreat it. 186*fcf3ce44SJohn Forte * return - error code. 187*fcf3ce44SJohn Forte * 188*fcf3ce44SJohn Forte * **************************************************************************** 189*fcf3ce44SJohn Forte */ 190*fcf3ce44SJohn Forte int 191*fcf3ce44SJohn Forte cache_unlock( 192*fcf3ce44SJohn Forte int mode, 193*fcf3ce44SJohn Forte int ec 194*fcf3ce44SJohn Forte ) 195*fcf3ce44SJohn Forte { 196*fcf3ce44SJohn Forte if (mode != CACHE_NO_ACTION) { 197*fcf3ce44SJohn Forte /* sync between cache and data store */ 198*fcf3ce44SJohn Forte if (mode == CACHE_WRITE) { 199*fcf3ce44SJohn Forte if (sys_q) { 200*fcf3ce44SJohn Forte ec = data_sync(ec); 201*fcf3ce44SJohn Forte } 202*fcf3ce44SJohn Forte 203*fcf3ce44SJohn Forte /* rest the cache update flag */ 204*fcf3ce44SJohn Forte RESET_CACHE_UPDATED(); 205*fcf3ce44SJohn Forte } 206*fcf3ce44SJohn Forte 207*fcf3ce44SJohn Forte ASSERT(!IS_CACHE_UPDATED()); 208*fcf3ce44SJohn Forte 209*fcf3ce44SJohn Forte /* unlock it */ 210*fcf3ce44SJohn Forte (void) rw_unlock(&imc->l); 211*fcf3ce44SJohn Forte #ifdef DEBUG 212*fcf3ce44SJohn Forte if (verbose_lock) { 213*fcf3ce44SJohn Forte printf("cache unlocked.\n"); 214*fcf3ce44SJohn Forte } 215*fcf3ce44SJohn Forte #endif 216*fcf3ce44SJohn Forte } 217*fcf3ce44SJohn Forte 218*fcf3ce44SJohn Forte return (ec); 219*fcf3ce44SJohn Forte } 220*fcf3ce44SJohn Forte 221*fcf3ce44SJohn Forte /* 222*fcf3ce44SJohn Forte * **************************************************************************** 223*fcf3ce44SJohn Forte * cache_lock_read: 224*fcf3ce44SJohn Forte * grab the read lock on the cache. 225*fcf3ce44SJohn Forte * 226*fcf3ce44SJohn Forte * return - error code. 227*fcf3ce44SJohn Forte * 228*fcf3ce44SJohn Forte * **************************************************************************** 229*fcf3ce44SJohn Forte */ 230*fcf3ce44SJohn Forte int 231*fcf3ce44SJohn Forte cache_lock_read( 232*fcf3ce44SJohn Forte ) 233*fcf3ce44SJohn Forte { 234*fcf3ce44SJohn Forte return (cache_lock(CACHE_READ)); 235*fcf3ce44SJohn Forte } 236*fcf3ce44SJohn Forte 237*fcf3ce44SJohn Forte /* 238*fcf3ce44SJohn Forte * **************************************************************************** 239*fcf3ce44SJohn Forte * cache_lock_write: 240*fcf3ce44SJohn Forte * grab the write lock on the cache. 241*fcf3ce44SJohn Forte * 242*fcf3ce44SJohn Forte * return - error code. 243*fcf3ce44SJohn Forte * 244*fcf3ce44SJohn Forte * **************************************************************************** 245*fcf3ce44SJohn Forte */ 246*fcf3ce44SJohn Forte int 247*fcf3ce44SJohn Forte cache_lock_write( 248*fcf3ce44SJohn Forte ) 249*fcf3ce44SJohn Forte { 250*fcf3ce44SJohn Forte return (cache_lock(CACHE_WRITE)); 251*fcf3ce44SJohn Forte } 252*fcf3ce44SJohn Forte 253*fcf3ce44SJohn Forte /* 254*fcf3ce44SJohn Forte * **************************************************************************** 255*fcf3ce44SJohn Forte * cache_unlock_sync: 256*fcf3ce44SJohn Forte * synchronize the cache with persistent data store and 257*fcf3ce44SJohn Forte * release the lock. 258*fcf3ce44SJohn Forte * 259*fcf3ce44SJohn Forte * ec - 0: commit the cache update; otherwise retreat it. 260*fcf3ce44SJohn Forte * return - error code. 261*fcf3ce44SJohn Forte * 262*fcf3ce44SJohn Forte * **************************************************************************** 263*fcf3ce44SJohn Forte */ 264*fcf3ce44SJohn Forte int 265*fcf3ce44SJohn Forte cache_unlock_sync( 266*fcf3ce44SJohn Forte int ec 267*fcf3ce44SJohn Forte ) 268*fcf3ce44SJohn Forte { 269*fcf3ce44SJohn Forte return (cache_unlock(CACHE_WRITE, ec)); 270*fcf3ce44SJohn Forte } 271*fcf3ce44SJohn Forte 272*fcf3ce44SJohn Forte /* 273*fcf3ce44SJohn Forte * **************************************************************************** 274*fcf3ce44SJohn Forte * cache_unlock_nosync: 275*fcf3ce44SJohn Forte * release the lock, no need to sync the data between cache and 276*fcf3ce44SJohn Forte * data store. 277*fcf3ce44SJohn Forte * if the cache has been updated, do not call this function, call 278*fcf3ce44SJohn Forte * cache_unlock_sync() with non-zero error code to indicate the 279*fcf3ce44SJohn Forte * sync action. 280*fcf3ce44SJohn Forte * 281*fcf3ce44SJohn Forte * return - error code. 282*fcf3ce44SJohn Forte * 283*fcf3ce44SJohn Forte * **************************************************************************** 284*fcf3ce44SJohn Forte */ 285*fcf3ce44SJohn Forte int 286*fcf3ce44SJohn Forte cache_unlock_nosync( 287*fcf3ce44SJohn Forte ) 288*fcf3ce44SJohn Forte { 289*fcf3ce44SJohn Forte return (cache_unlock(CACHE_READ, 0)); 290*fcf3ce44SJohn Forte } 291*fcf3ce44SJohn Forte 292*fcf3ce44SJohn Forte /* 293*fcf3ce44SJohn Forte * **************************************************************************** 294*fcf3ce44SJohn Forte * cache_get_htab: 295*fcf3ce44SJohn Forte * get the hash table for individual type of object. 296*fcf3ce44SJohn Forte * 297*fcf3ce44SJohn Forte * type - the object type. 298*fcf3ce44SJohn Forte * return - the hash table. 299*fcf3ce44SJohn Forte * 300*fcf3ce44SJohn Forte * **************************************************************************** 301*fcf3ce44SJohn Forte */ 302*fcf3ce44SJohn Forte htab_t * 303*fcf3ce44SJohn Forte cache_get_htab( 304*fcf3ce44SJohn Forte isns_type_t type 305*fcf3ce44SJohn Forte ) 306*fcf3ce44SJohn Forte { 307*fcf3ce44SJohn Forte if (type > 0 && type < MAX_OBJ_TYPE) { 308*fcf3ce44SJohn Forte return (imc->t[type]); 309*fcf3ce44SJohn Forte } 310*fcf3ce44SJohn Forte 311*fcf3ce44SJohn Forte return (NULL); 312*fcf3ce44SJohn Forte } 313*fcf3ce44SJohn Forte 314*fcf3ce44SJohn Forte /* 315*fcf3ce44SJohn Forte * **************************************************************************** 316*fcf3ce44SJohn Forte * cache_get_matrix: 317*fcf3ce44SJohn Forte * get the membership matrix for a discovery domain or a 318*fcf3ce44SJohn Forte * discovery domain set. 319*fcf3ce44SJohn Forte * 320*fcf3ce44SJohn Forte * type - the discovery domain or discovery domain set object type. 321*fcf3ce44SJohn Forte * return - the matrix. 322*fcf3ce44SJohn Forte * 323*fcf3ce44SJohn Forte * **************************************************************************** 324*fcf3ce44SJohn Forte */ 325*fcf3ce44SJohn Forte matrix_t * 326*fcf3ce44SJohn Forte cache_get_matrix( 327*fcf3ce44SJohn Forte isns_type_t type 328*fcf3ce44SJohn Forte ) 329*fcf3ce44SJohn Forte { 330*fcf3ce44SJohn Forte matrix_t *x = NULL; 331*fcf3ce44SJohn Forte 332*fcf3ce44SJohn Forte switch (type) { 333*fcf3ce44SJohn Forte case OBJ_DD: 334*fcf3ce44SJohn Forte x = imc->x[0]; 335*fcf3ce44SJohn Forte break; 336*fcf3ce44SJohn Forte case OBJ_DDS: 337*fcf3ce44SJohn Forte x = imc->x[1]; 338*fcf3ce44SJohn Forte break; 339*fcf3ce44SJohn Forte default: 340*fcf3ce44SJohn Forte break; 341*fcf3ce44SJohn Forte } 342*fcf3ce44SJohn Forte 343*fcf3ce44SJohn Forte return (x); 344*fcf3ce44SJohn Forte } 345*fcf3ce44SJohn Forte 346*fcf3ce44SJohn Forte /* 347*fcf3ce44SJohn Forte * **************************************************************************** 348*fcf3ce44SJohn Forte * cache_lookup: 349*fcf3ce44SJohn Forte * invoke the hash table lookup for looking up a specific object and 350*fcf3ce44SJohn Forte * perform the callback function on the object. 351*fcf3ce44SJohn Forte * 352*fcf3ce44SJohn Forte * lcp - the object lookup control data. 353*fcf3ce44SJohn Forte * uid_p - the pointer of object UID for returning. 354*fcf3ce44SJohn Forte * callback - the callback function for the object. 355*fcf3ce44SJohn Forte * return - error code. 356*fcf3ce44SJohn Forte * 357*fcf3ce44SJohn Forte * **************************************************************************** 358*fcf3ce44SJohn Forte */ 359*fcf3ce44SJohn Forte int 360*fcf3ce44SJohn Forte cache_lookup( 361*fcf3ce44SJohn Forte lookup_ctrl_t *lcp, 362*fcf3ce44SJohn Forte uint32_t *uid_p, 363*fcf3ce44SJohn Forte int (*callback)(void *, void *) 364*fcf3ce44SJohn Forte ) 365*fcf3ce44SJohn Forte { 366*fcf3ce44SJohn Forte return (htab_lookup(imc->t[lcp->type], 367*fcf3ce44SJohn Forte lcp, 368*fcf3ce44SJohn Forte (lcp->op[0] == OP_INTEGER) ? lcp->data[0].ui : 0, 369*fcf3ce44SJohn Forte uid_p, 370*fcf3ce44SJohn Forte callback, 371*fcf3ce44SJohn Forte 0)); 372*fcf3ce44SJohn Forte } 373*fcf3ce44SJohn Forte 374*fcf3ce44SJohn Forte /* 375*fcf3ce44SJohn Forte * **************************************************************************** 376*fcf3ce44SJohn Forte * cache_lookup: 377*fcf3ce44SJohn Forte * invoke the hash table lookup for looking up a specific object, 378*fcf3ce44SJohn Forte * the callback function is going to change the key of the object. 379*fcf3ce44SJohn Forte * 380*fcf3ce44SJohn Forte * lcp - the object lookup control data. 381*fcf3ce44SJohn Forte * uid_p - the pointer of object UID for returning. 382*fcf3ce44SJohn Forte * callback - the callback function for the object. 383*fcf3ce44SJohn Forte * return - error code. 384*fcf3ce44SJohn Forte * 385*fcf3ce44SJohn Forte * **************************************************************************** 386*fcf3ce44SJohn Forte */ 387*fcf3ce44SJohn Forte int 388*fcf3ce44SJohn Forte cache_rekey( 389*fcf3ce44SJohn Forte lookup_ctrl_t *lcp, 390*fcf3ce44SJohn Forte uint32_t *uid_p, 391*fcf3ce44SJohn Forte int (*callback)(void *, void *) 392*fcf3ce44SJohn Forte ) 393*fcf3ce44SJohn Forte { 394*fcf3ce44SJohn Forte return (htab_lookup(imc->t[lcp->type], 395*fcf3ce44SJohn Forte lcp, 396*fcf3ce44SJohn Forte (lcp->op[0] == OP_INTEGER) ? lcp->data[0].ui : 0, 397*fcf3ce44SJohn Forte uid_p, 398*fcf3ce44SJohn Forte callback, 399*fcf3ce44SJohn Forte 1)); 400*fcf3ce44SJohn Forte } 401*fcf3ce44SJohn Forte 402*fcf3ce44SJohn Forte /* 403*fcf3ce44SJohn Forte * **************************************************************************** 404*fcf3ce44SJohn Forte * cache_add: 405*fcf3ce44SJohn Forte * invoke hash table add to add an object. 406*fcf3ce44SJohn Forte * 407*fcf3ce44SJohn Forte * obj - the object being added. 408*fcf3ce44SJohn Forte * flag - 0: a real object; 409*fcf3ce44SJohn Forte * otherwise an association object for discovery domain membership. 410*fcf3ce44SJohn Forte * uid_p - the pointer of object UID for returning. 411*fcf3ce44SJohn Forte * update_p - the pointer of flag (update object or newly register) 412*fcf3ce44SJohn Forte * for returning. 413*fcf3ce44SJohn Forte * return - error code. 414*fcf3ce44SJohn Forte * 415*fcf3ce44SJohn Forte * **************************************************************************** 416*fcf3ce44SJohn Forte */ 417*fcf3ce44SJohn Forte int 418*fcf3ce44SJohn Forte cache_add( 419*fcf3ce44SJohn Forte isns_obj_t *obj, 420*fcf3ce44SJohn Forte int flag, 421*fcf3ce44SJohn Forte uint32_t *uid_p, 422*fcf3ce44SJohn Forte int *update_p 423*fcf3ce44SJohn Forte ) 424*fcf3ce44SJohn Forte { 425*fcf3ce44SJohn Forte return (htab_add(imc->t[obj->type], obj, flag, uid_p, update_p)); 426*fcf3ce44SJohn Forte } 427*fcf3ce44SJohn Forte 428*fcf3ce44SJohn Forte /* 429*fcf3ce44SJohn Forte * **************************************************************************** 430*fcf3ce44SJohn Forte * cache_remove: 431*fcf3ce44SJohn Forte * invoke hash table remove to remove an object. 432*fcf3ce44SJohn Forte * 433*fcf3ce44SJohn Forte * lcp - the lookup control data for the object being removed. 434*fcf3ce44SJohn Forte * flag - 0: a real object; 435*fcf3ce44SJohn Forte * otherwise an association object for discovery domain membership. 436*fcf3ce44SJohn Forte * return - the removed object. 437*fcf3ce44SJohn Forte * 438*fcf3ce44SJohn Forte * **************************************************************************** 439*fcf3ce44SJohn Forte */ 440*fcf3ce44SJohn Forte isns_obj_t * 441*fcf3ce44SJohn Forte cache_remove( 442*fcf3ce44SJohn Forte lookup_ctrl_t *lcp, 443*fcf3ce44SJohn Forte int flag 444*fcf3ce44SJohn Forte ) 445*fcf3ce44SJohn Forte { 446*fcf3ce44SJohn Forte return (htab_remove(imc->t[lcp->type], 447*fcf3ce44SJohn Forte lcp, 448*fcf3ce44SJohn Forte (lcp->op[0] == OP_INTEGER) ? lcp->data[0].ui : 0, 449*fcf3ce44SJohn Forte flag)); 450*fcf3ce44SJohn Forte } 451*fcf3ce44SJohn Forte 452*fcf3ce44SJohn Forte /* 453*fcf3ce44SJohn Forte * **************************************************************************** 454*fcf3ce44SJohn Forte * cache_dump_htab: 455*fcf3ce44SJohn Forte * dump the hash table for debugging purpose. 456*fcf3ce44SJohn Forte * 457*fcf3ce44SJohn Forte * type - the object type. 458*fcf3ce44SJohn Forte * 459*fcf3ce44SJohn Forte * **************************************************************************** 460*fcf3ce44SJohn Forte */ 461*fcf3ce44SJohn Forte #ifdef DEBUG 462*fcf3ce44SJohn Forte void 463*fcf3ce44SJohn Forte cache_dump_htab( 464*fcf3ce44SJohn Forte isns_type_t type 465*fcf3ce44SJohn Forte ) 466*fcf3ce44SJohn Forte { 467*fcf3ce44SJohn Forte (void) htab_dump(imc->t[type]); 468*fcf3ce44SJohn Forte } 469*fcf3ce44SJohn Forte #endif 470