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