1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM *
4*7836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM *
8*7836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM * and limitations under the License.
12*7836SJohn.Forte@Sun.COM *
13*7836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM *
19*7836SJohn.Forte@Sun.COM * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM */
21*7836SJohn.Forte@Sun.COM
22*7836SJohn.Forte@Sun.COM /*
23*7836SJohn.Forte@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24*7836SJohn.Forte@Sun.COM * Use is subject to license terms.
25*7836SJohn.Forte@Sun.COM */
26*7836SJohn.Forte@Sun.COM
27*7836SJohn.Forte@Sun.COM #include <stdio.h>
28*7836SJohn.Forte@Sun.COM #include <stdlib.h>
29*7836SJohn.Forte@Sun.COM #ifdef DEBUG
30*7836SJohn.Forte@Sun.COM #include <time.h>
31*7836SJohn.Forte@Sun.COM #endif
32*7836SJohn.Forte@Sun.COM
33*7836SJohn.Forte@Sun.COM #include "isns_server.h"
34*7836SJohn.Forte@Sun.COM #include "isns_cache.h"
35*7836SJohn.Forte@Sun.COM #include "isns_obj.h"
36*7836SJohn.Forte@Sun.COM #include "isns_log.h"
37*7836SJohn.Forte@Sun.COM
38*7836SJohn.Forte@Sun.COM #ifndef TARGET_DATA_STORE
39*7836SJohn.Forte@Sun.COM #define TARGET_DATA_STORE xml
40*7836SJohn.Forte@Sun.COM #endif
41*7836SJohn.Forte@Sun.COM
42*7836SJohn.Forte@Sun.COM #define TARGET_src(TARGET) XTARGET_src(TARGET)
43*7836SJohn.Forte@Sun.COM #define XTARGET_src(TARGET) XXTARGET_src(TARGET/data.c)
44*7836SJohn.Forte@Sun.COM #define XXTARGET_src(TARGET) #TARGET
45*7836SJohn.Forte@Sun.COM
46*7836SJohn.Forte@Sun.COM #include TARGET_src(TARGET_DATA_STORE)
47*7836SJohn.Forte@Sun.COM
48*7836SJohn.Forte@Sun.COM #define TARGET_func(func) XTARGET_func(TARGET_DATA_STORE, func)
49*7836SJohn.Forte@Sun.COM #define XTARGET_func(TARGET, func) XXTARGET_func(TARGET, func)
50*7836SJohn.Forte@Sun.COM #define XXTARGET_func(TARGET, func) TARGET ## func
51*7836SJohn.Forte@Sun.COM
52*7836SJohn.Forte@Sun.COM #ifdef DEBUG
53*7836SJohn.Forte@Sun.COM static time_t total_time = 0;
54*7836SJohn.Forte@Sun.COM static clock_t total_clock = 0;
55*7836SJohn.Forte@Sun.COM extern int verbose_tc;
56*7836SJohn.Forte@Sun.COM #endif
57*7836SJohn.Forte@Sun.COM
58*7836SJohn.Forte@Sun.COM int
target_init_data()59*7836SJohn.Forte@Sun.COM target_init_data(
60*7836SJohn.Forte@Sun.COM )
61*7836SJohn.Forte@Sun.COM {
62*7836SJohn.Forte@Sun.COM return (TARGET_func(_init_data)());
63*7836SJohn.Forte@Sun.COM }
64*7836SJohn.Forte@Sun.COM
65*7836SJohn.Forte@Sun.COM int
target_load_obj(void ** p,isns_obj_t ** objp,uchar_t * phase)66*7836SJohn.Forte@Sun.COM target_load_obj(
67*7836SJohn.Forte@Sun.COM void **p,
68*7836SJohn.Forte@Sun.COM isns_obj_t **objp,
69*7836SJohn.Forte@Sun.COM uchar_t *phase
70*7836SJohn.Forte@Sun.COM )
71*7836SJohn.Forte@Sun.COM {
72*7836SJohn.Forte@Sun.COM return (TARGET_func(_load_obj)(p, objp, phase));
73*7836SJohn.Forte@Sun.COM }
74*7836SJohn.Forte@Sun.COM
75*7836SJohn.Forte@Sun.COM int
target_add_obj(const isns_obj_t * obj)76*7836SJohn.Forte@Sun.COM target_add_obj(
77*7836SJohn.Forte@Sun.COM const isns_obj_t *obj
78*7836SJohn.Forte@Sun.COM )
79*7836SJohn.Forte@Sun.COM {
80*7836SJohn.Forte@Sun.COM int status;
81*7836SJohn.Forte@Sun.COM #ifdef DEBUG
82*7836SJohn.Forte@Sun.COM time_t t;
83*7836SJohn.Forte@Sun.COM clock_t c;
84*7836SJohn.Forte@Sun.COM if (verbose_tc != 0) {
85*7836SJohn.Forte@Sun.COM t = time(NULL);
86*7836SJohn.Forte@Sun.COM c = clock();
87*7836SJohn.Forte@Sun.COM }
88*7836SJohn.Forte@Sun.COM #endif
89*7836SJohn.Forte@Sun.COM status = TARGET_func(_add_obj)(obj);
90*7836SJohn.Forte@Sun.COM #ifdef DEBUG
91*7836SJohn.Forte@Sun.COM if (verbose_tc != 0) {
92*7836SJohn.Forte@Sun.COM t = time(NULL) - t;
93*7836SJohn.Forte@Sun.COM c = clock() - c;
94*7836SJohn.Forte@Sun.COM total_time += t;
95*7836SJohn.Forte@Sun.COM total_clock += c;
96*7836SJohn.Forte@Sun.COM printf("time %d clock %.4lf -adding one object\n",
97*7836SJohn.Forte@Sun.COM t, c / (double)CLOCKS_PER_SEC);
98*7836SJohn.Forte@Sun.COM }
99*7836SJohn.Forte@Sun.COM #endif
100*7836SJohn.Forte@Sun.COM return (status);
101*7836SJohn.Forte@Sun.COM }
102*7836SJohn.Forte@Sun.COM
103*7836SJohn.Forte@Sun.COM int
target_modify_obj(const isns_obj_t * obj)104*7836SJohn.Forte@Sun.COM target_modify_obj(
105*7836SJohn.Forte@Sun.COM const isns_obj_t *obj
106*7836SJohn.Forte@Sun.COM )
107*7836SJohn.Forte@Sun.COM {
108*7836SJohn.Forte@Sun.COM int status;
109*7836SJohn.Forte@Sun.COM #ifdef DEBUG
110*7836SJohn.Forte@Sun.COM time_t t;
111*7836SJohn.Forte@Sun.COM clock_t c;
112*7836SJohn.Forte@Sun.COM if (verbose_tc != 0) {
113*7836SJohn.Forte@Sun.COM t = time(NULL);
114*7836SJohn.Forte@Sun.COM c = clock();
115*7836SJohn.Forte@Sun.COM }
116*7836SJohn.Forte@Sun.COM #endif
117*7836SJohn.Forte@Sun.COM status = TARGET_func(_modify_obj)(obj);
118*7836SJohn.Forte@Sun.COM #ifdef DEBUG
119*7836SJohn.Forte@Sun.COM if (verbose_tc != 0) {
120*7836SJohn.Forte@Sun.COM t = time(NULL) - t;
121*7836SJohn.Forte@Sun.COM c = clock() - c;
122*7836SJohn.Forte@Sun.COM total_time += t;
123*7836SJohn.Forte@Sun.COM total_clock += c;
124*7836SJohn.Forte@Sun.COM printf("time %d clock %.4lf -updating one object\n",
125*7836SJohn.Forte@Sun.COM t, c / (double)CLOCKS_PER_SEC);
126*7836SJohn.Forte@Sun.COM }
127*7836SJohn.Forte@Sun.COM #endif
128*7836SJohn.Forte@Sun.COM return (status);
129*7836SJohn.Forte@Sun.COM }
130*7836SJohn.Forte@Sun.COM
131*7836SJohn.Forte@Sun.COM int
target_delete_obj(const isns_obj_t * obj)132*7836SJohn.Forte@Sun.COM target_delete_obj(
133*7836SJohn.Forte@Sun.COM const isns_obj_t *obj
134*7836SJohn.Forte@Sun.COM )
135*7836SJohn.Forte@Sun.COM {
136*7836SJohn.Forte@Sun.COM int status;
137*7836SJohn.Forte@Sun.COM #ifdef DEBUG
138*7836SJohn.Forte@Sun.COM time_t t;
139*7836SJohn.Forte@Sun.COM clock_t c;
140*7836SJohn.Forte@Sun.COM if (verbose_tc != 0) {
141*7836SJohn.Forte@Sun.COM t = time(NULL);
142*7836SJohn.Forte@Sun.COM c = clock();
143*7836SJohn.Forte@Sun.COM }
144*7836SJohn.Forte@Sun.COM #endif
145*7836SJohn.Forte@Sun.COM status = TARGET_func(_delete_obj)(obj);
146*7836SJohn.Forte@Sun.COM #ifdef DEBUG
147*7836SJohn.Forte@Sun.COM if (verbose_tc != 0) {
148*7836SJohn.Forte@Sun.COM t = time(NULL) - t;
149*7836SJohn.Forte@Sun.COM c = clock() - c;
150*7836SJohn.Forte@Sun.COM total_time += t;
151*7836SJohn.Forte@Sun.COM total_clock += c;
152*7836SJohn.Forte@Sun.COM printf("time %d clock %.4lf -deleting one object\n",
153*7836SJohn.Forte@Sun.COM t, c / (double)CLOCKS_PER_SEC);
154*7836SJohn.Forte@Sun.COM }
155*7836SJohn.Forte@Sun.COM #endif
156*7836SJohn.Forte@Sun.COM return (status);
157*7836SJohn.Forte@Sun.COM }
158*7836SJohn.Forte@Sun.COM
159*7836SJohn.Forte@Sun.COM int
target_delete_assoc(const isns_obj_t * obj)160*7836SJohn.Forte@Sun.COM target_delete_assoc(
161*7836SJohn.Forte@Sun.COM const isns_obj_t *obj
162*7836SJohn.Forte@Sun.COM )
163*7836SJohn.Forte@Sun.COM {
164*7836SJohn.Forte@Sun.COM int status;
165*7836SJohn.Forte@Sun.COM #ifdef DEBUG
166*7836SJohn.Forte@Sun.COM time_t t;
167*7836SJohn.Forte@Sun.COM clock_t c;
168*7836SJohn.Forte@Sun.COM if (verbose_tc != 0) {
169*7836SJohn.Forte@Sun.COM t = time(NULL);
170*7836SJohn.Forte@Sun.COM c = clock();
171*7836SJohn.Forte@Sun.COM }
172*7836SJohn.Forte@Sun.COM #endif
173*7836SJohn.Forte@Sun.COM status = TARGET_func(_delete_assoc)(obj);
174*7836SJohn.Forte@Sun.COM #ifdef DEBUG
175*7836SJohn.Forte@Sun.COM if (verbose_tc != 0) {
176*7836SJohn.Forte@Sun.COM t = time(NULL) - t;
177*7836SJohn.Forte@Sun.COM c = clock() - c;
178*7836SJohn.Forte@Sun.COM total_time += t;
179*7836SJohn.Forte@Sun.COM total_clock += c;
180*7836SJohn.Forte@Sun.COM printf("time %d clock %.4lf -deleting one membership\n",
181*7836SJohn.Forte@Sun.COM t, c / (double)CLOCKS_PER_SEC);
182*7836SJohn.Forte@Sun.COM }
183*7836SJohn.Forte@Sun.COM #endif
184*7836SJohn.Forte@Sun.COM return (status);
185*7836SJohn.Forte@Sun.COM }
186*7836SJohn.Forte@Sun.COM
187*7836SJohn.Forte@Sun.COM int
target_update_commit()188*7836SJohn.Forte@Sun.COM target_update_commit(
189*7836SJohn.Forte@Sun.COM )
190*7836SJohn.Forte@Sun.COM {
191*7836SJohn.Forte@Sun.COM int status;
192*7836SJohn.Forte@Sun.COM #ifdef DEBUG
193*7836SJohn.Forte@Sun.COM time_t t;
194*7836SJohn.Forte@Sun.COM clock_t c;
195*7836SJohn.Forte@Sun.COM if (verbose_tc != 0) {
196*7836SJohn.Forte@Sun.COM t = time(NULL);
197*7836SJohn.Forte@Sun.COM c = clock();
198*7836SJohn.Forte@Sun.COM }
199*7836SJohn.Forte@Sun.COM #endif
200*7836SJohn.Forte@Sun.COM status = TARGET_func(_update_commit)();
201*7836SJohn.Forte@Sun.COM #ifdef DEBUG
202*7836SJohn.Forte@Sun.COM if (verbose_tc != 0) {
203*7836SJohn.Forte@Sun.COM t = time(NULL) - t;
204*7836SJohn.Forte@Sun.COM c = clock() - c;
205*7836SJohn.Forte@Sun.COM total_time += t;
206*7836SJohn.Forte@Sun.COM total_clock += c;
207*7836SJohn.Forte@Sun.COM printf("time %d clock %.4lf -flushing the data\n",
208*7836SJohn.Forte@Sun.COM t, c / (double)CLOCKS_PER_SEC);
209*7836SJohn.Forte@Sun.COM printf("time %d clock %.4lf -total update\n",
210*7836SJohn.Forte@Sun.COM total_time, total_clock / (double)CLOCKS_PER_SEC);
211*7836SJohn.Forte@Sun.COM total_time = 0;
212*7836SJohn.Forte@Sun.COM total_clock = 0;
213*7836SJohn.Forte@Sun.COM }
214*7836SJohn.Forte@Sun.COM #endif
215*7836SJohn.Forte@Sun.COM return (status);
216*7836SJohn.Forte@Sun.COM }
217*7836SJohn.Forte@Sun.COM
218*7836SJohn.Forte@Sun.COM int
target_update_retreat()219*7836SJohn.Forte@Sun.COM target_update_retreat(
220*7836SJohn.Forte@Sun.COM )
221*7836SJohn.Forte@Sun.COM {
222*7836SJohn.Forte@Sun.COM int status;
223*7836SJohn.Forte@Sun.COM #ifdef DEBUG
224*7836SJohn.Forte@Sun.COM time_t t;
225*7836SJohn.Forte@Sun.COM clock_t c;
226*7836SJohn.Forte@Sun.COM if (verbose_tc != 0) {
227*7836SJohn.Forte@Sun.COM t = time(NULL);
228*7836SJohn.Forte@Sun.COM c = clock();
229*7836SJohn.Forte@Sun.COM }
230*7836SJohn.Forte@Sun.COM #endif
231*7836SJohn.Forte@Sun.COM status = TARGET_func(_update_retreat)();
232*7836SJohn.Forte@Sun.COM #ifdef DEBUG
233*7836SJohn.Forte@Sun.COM if (verbose_tc != 0) {
234*7836SJohn.Forte@Sun.COM t = time(NULL) - t;
235*7836SJohn.Forte@Sun.COM c = clock() - c;
236*7836SJohn.Forte@Sun.COM total_time += t;
237*7836SJohn.Forte@Sun.COM total_clock += c;
238*7836SJohn.Forte@Sun.COM printf("time %d clock %.4lf -flushing the data\n",
239*7836SJohn.Forte@Sun.COM t, c / (double)CLOCKS_PER_SEC);
240*7836SJohn.Forte@Sun.COM printf("time %d clock %.4lf -total update\n",
241*7836SJohn.Forte@Sun.COM total_time, total_clock / (double)CLOCKS_PER_SEC);
242*7836SJohn.Forte@Sun.COM total_time = 0;
243*7836SJohn.Forte@Sun.COM total_clock = 0;
244*7836SJohn.Forte@Sun.COM }
245*7836SJohn.Forte@Sun.COM #endif
246*7836SJohn.Forte@Sun.COM return (status);
247*7836SJohn.Forte@Sun.COM }
248