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 #ifdef DEBUG 30*fcf3ce44SJohn Forte #include <time.h> 31*fcf3ce44SJohn Forte #endif 32*fcf3ce44SJohn Forte 33*fcf3ce44SJohn Forte #include "isns_server.h" 34*fcf3ce44SJohn Forte #include "isns_cache.h" 35*fcf3ce44SJohn Forte #include "isns_obj.h" 36*fcf3ce44SJohn Forte #include "isns_log.h" 37*fcf3ce44SJohn Forte 38*fcf3ce44SJohn Forte #ifndef TARGET_DATA_STORE 39*fcf3ce44SJohn Forte #define TARGET_DATA_STORE xml 40*fcf3ce44SJohn Forte #endif 41*fcf3ce44SJohn Forte 42*fcf3ce44SJohn Forte #define TARGET_src(TARGET) XTARGET_src(TARGET) 43*fcf3ce44SJohn Forte #define XTARGET_src(TARGET) XXTARGET_src(TARGET/data.c) 44*fcf3ce44SJohn Forte #define XXTARGET_src(TARGET) #TARGET 45*fcf3ce44SJohn Forte 46*fcf3ce44SJohn Forte #include TARGET_src(TARGET_DATA_STORE) 47*fcf3ce44SJohn Forte 48*fcf3ce44SJohn Forte #define TARGET_func(func) XTARGET_func(TARGET_DATA_STORE, func) 49*fcf3ce44SJohn Forte #define XTARGET_func(TARGET, func) XXTARGET_func(TARGET, func) 50*fcf3ce44SJohn Forte #define XXTARGET_func(TARGET, func) TARGET ## func 51*fcf3ce44SJohn Forte 52*fcf3ce44SJohn Forte #ifdef DEBUG 53*fcf3ce44SJohn Forte static time_t total_time = 0; 54*fcf3ce44SJohn Forte static clock_t total_clock = 0; 55*fcf3ce44SJohn Forte extern int verbose_tc; 56*fcf3ce44SJohn Forte #endif 57*fcf3ce44SJohn Forte 58*fcf3ce44SJohn Forte int 59*fcf3ce44SJohn Forte target_init_data( 60*fcf3ce44SJohn Forte ) 61*fcf3ce44SJohn Forte { 62*fcf3ce44SJohn Forte return (TARGET_func(_init_data)()); 63*fcf3ce44SJohn Forte } 64*fcf3ce44SJohn Forte 65*fcf3ce44SJohn Forte int 66*fcf3ce44SJohn Forte target_load_obj( 67*fcf3ce44SJohn Forte void **p, 68*fcf3ce44SJohn Forte isns_obj_t **objp, 69*fcf3ce44SJohn Forte uchar_t *phase 70*fcf3ce44SJohn Forte ) 71*fcf3ce44SJohn Forte { 72*fcf3ce44SJohn Forte return (TARGET_func(_load_obj)(p, objp, phase)); 73*fcf3ce44SJohn Forte } 74*fcf3ce44SJohn Forte 75*fcf3ce44SJohn Forte int 76*fcf3ce44SJohn Forte target_add_obj( 77*fcf3ce44SJohn Forte const isns_obj_t *obj 78*fcf3ce44SJohn Forte ) 79*fcf3ce44SJohn Forte { 80*fcf3ce44SJohn Forte int status; 81*fcf3ce44SJohn Forte #ifdef DEBUG 82*fcf3ce44SJohn Forte time_t t; 83*fcf3ce44SJohn Forte clock_t c; 84*fcf3ce44SJohn Forte if (verbose_tc != 0) { 85*fcf3ce44SJohn Forte t = time(NULL); 86*fcf3ce44SJohn Forte c = clock(); 87*fcf3ce44SJohn Forte } 88*fcf3ce44SJohn Forte #endif 89*fcf3ce44SJohn Forte status = TARGET_func(_add_obj)(obj); 90*fcf3ce44SJohn Forte #ifdef DEBUG 91*fcf3ce44SJohn Forte if (verbose_tc != 0) { 92*fcf3ce44SJohn Forte t = time(NULL) - t; 93*fcf3ce44SJohn Forte c = clock() - c; 94*fcf3ce44SJohn Forte total_time += t; 95*fcf3ce44SJohn Forte total_clock += c; 96*fcf3ce44SJohn Forte printf("time %d clock %.4lf -adding one object\n", 97*fcf3ce44SJohn Forte t, c / (double)CLOCKS_PER_SEC); 98*fcf3ce44SJohn Forte } 99*fcf3ce44SJohn Forte #endif 100*fcf3ce44SJohn Forte return (status); 101*fcf3ce44SJohn Forte } 102*fcf3ce44SJohn Forte 103*fcf3ce44SJohn Forte int 104*fcf3ce44SJohn Forte target_modify_obj( 105*fcf3ce44SJohn Forte const isns_obj_t *obj 106*fcf3ce44SJohn Forte ) 107*fcf3ce44SJohn Forte { 108*fcf3ce44SJohn Forte int status; 109*fcf3ce44SJohn Forte #ifdef DEBUG 110*fcf3ce44SJohn Forte time_t t; 111*fcf3ce44SJohn Forte clock_t c; 112*fcf3ce44SJohn Forte if (verbose_tc != 0) { 113*fcf3ce44SJohn Forte t = time(NULL); 114*fcf3ce44SJohn Forte c = clock(); 115*fcf3ce44SJohn Forte } 116*fcf3ce44SJohn Forte #endif 117*fcf3ce44SJohn Forte status = TARGET_func(_modify_obj)(obj); 118*fcf3ce44SJohn Forte #ifdef DEBUG 119*fcf3ce44SJohn Forte if (verbose_tc != 0) { 120*fcf3ce44SJohn Forte t = time(NULL) - t; 121*fcf3ce44SJohn Forte c = clock() - c; 122*fcf3ce44SJohn Forte total_time += t; 123*fcf3ce44SJohn Forte total_clock += c; 124*fcf3ce44SJohn Forte printf("time %d clock %.4lf -updating one object\n", 125*fcf3ce44SJohn Forte t, c / (double)CLOCKS_PER_SEC); 126*fcf3ce44SJohn Forte } 127*fcf3ce44SJohn Forte #endif 128*fcf3ce44SJohn Forte return (status); 129*fcf3ce44SJohn Forte } 130*fcf3ce44SJohn Forte 131*fcf3ce44SJohn Forte int 132*fcf3ce44SJohn Forte target_delete_obj( 133*fcf3ce44SJohn Forte const isns_obj_t *obj 134*fcf3ce44SJohn Forte ) 135*fcf3ce44SJohn Forte { 136*fcf3ce44SJohn Forte int status; 137*fcf3ce44SJohn Forte #ifdef DEBUG 138*fcf3ce44SJohn Forte time_t t; 139*fcf3ce44SJohn Forte clock_t c; 140*fcf3ce44SJohn Forte if (verbose_tc != 0) { 141*fcf3ce44SJohn Forte t = time(NULL); 142*fcf3ce44SJohn Forte c = clock(); 143*fcf3ce44SJohn Forte } 144*fcf3ce44SJohn Forte #endif 145*fcf3ce44SJohn Forte status = TARGET_func(_delete_obj)(obj); 146*fcf3ce44SJohn Forte #ifdef DEBUG 147*fcf3ce44SJohn Forte if (verbose_tc != 0) { 148*fcf3ce44SJohn Forte t = time(NULL) - t; 149*fcf3ce44SJohn Forte c = clock() - c; 150*fcf3ce44SJohn Forte total_time += t; 151*fcf3ce44SJohn Forte total_clock += c; 152*fcf3ce44SJohn Forte printf("time %d clock %.4lf -deleting one object\n", 153*fcf3ce44SJohn Forte t, c / (double)CLOCKS_PER_SEC); 154*fcf3ce44SJohn Forte } 155*fcf3ce44SJohn Forte #endif 156*fcf3ce44SJohn Forte return (status); 157*fcf3ce44SJohn Forte } 158*fcf3ce44SJohn Forte 159*fcf3ce44SJohn Forte int 160*fcf3ce44SJohn Forte target_delete_assoc( 161*fcf3ce44SJohn Forte const isns_obj_t *obj 162*fcf3ce44SJohn Forte ) 163*fcf3ce44SJohn Forte { 164*fcf3ce44SJohn Forte int status; 165*fcf3ce44SJohn Forte #ifdef DEBUG 166*fcf3ce44SJohn Forte time_t t; 167*fcf3ce44SJohn Forte clock_t c; 168*fcf3ce44SJohn Forte if (verbose_tc != 0) { 169*fcf3ce44SJohn Forte t = time(NULL); 170*fcf3ce44SJohn Forte c = clock(); 171*fcf3ce44SJohn Forte } 172*fcf3ce44SJohn Forte #endif 173*fcf3ce44SJohn Forte status = TARGET_func(_delete_assoc)(obj); 174*fcf3ce44SJohn Forte #ifdef DEBUG 175*fcf3ce44SJohn Forte if (verbose_tc != 0) { 176*fcf3ce44SJohn Forte t = time(NULL) - t; 177*fcf3ce44SJohn Forte c = clock() - c; 178*fcf3ce44SJohn Forte total_time += t; 179*fcf3ce44SJohn Forte total_clock += c; 180*fcf3ce44SJohn Forte printf("time %d clock %.4lf -deleting one membership\n", 181*fcf3ce44SJohn Forte t, c / (double)CLOCKS_PER_SEC); 182*fcf3ce44SJohn Forte } 183*fcf3ce44SJohn Forte #endif 184*fcf3ce44SJohn Forte return (status); 185*fcf3ce44SJohn Forte } 186*fcf3ce44SJohn Forte 187*fcf3ce44SJohn Forte int 188*fcf3ce44SJohn Forte target_update_commit( 189*fcf3ce44SJohn Forte ) 190*fcf3ce44SJohn Forte { 191*fcf3ce44SJohn Forte int status; 192*fcf3ce44SJohn Forte #ifdef DEBUG 193*fcf3ce44SJohn Forte time_t t; 194*fcf3ce44SJohn Forte clock_t c; 195*fcf3ce44SJohn Forte if (verbose_tc != 0) { 196*fcf3ce44SJohn Forte t = time(NULL); 197*fcf3ce44SJohn Forte c = clock(); 198*fcf3ce44SJohn Forte } 199*fcf3ce44SJohn Forte #endif 200*fcf3ce44SJohn Forte status = TARGET_func(_update_commit)(); 201*fcf3ce44SJohn Forte #ifdef DEBUG 202*fcf3ce44SJohn Forte if (verbose_tc != 0) { 203*fcf3ce44SJohn Forte t = time(NULL) - t; 204*fcf3ce44SJohn Forte c = clock() - c; 205*fcf3ce44SJohn Forte total_time += t; 206*fcf3ce44SJohn Forte total_clock += c; 207*fcf3ce44SJohn Forte printf("time %d clock %.4lf -flushing the data\n", 208*fcf3ce44SJohn Forte t, c / (double)CLOCKS_PER_SEC); 209*fcf3ce44SJohn Forte printf("time %d clock %.4lf -total update\n", 210*fcf3ce44SJohn Forte total_time, total_clock / (double)CLOCKS_PER_SEC); 211*fcf3ce44SJohn Forte total_time = 0; 212*fcf3ce44SJohn Forte total_clock = 0; 213*fcf3ce44SJohn Forte } 214*fcf3ce44SJohn Forte #endif 215*fcf3ce44SJohn Forte return (status); 216*fcf3ce44SJohn Forte } 217*fcf3ce44SJohn Forte 218*fcf3ce44SJohn Forte int 219*fcf3ce44SJohn Forte target_update_retreat( 220*fcf3ce44SJohn Forte ) 221*fcf3ce44SJohn Forte { 222*fcf3ce44SJohn Forte int status; 223*fcf3ce44SJohn Forte #ifdef DEBUG 224*fcf3ce44SJohn Forte time_t t; 225*fcf3ce44SJohn Forte clock_t c; 226*fcf3ce44SJohn Forte if (verbose_tc != 0) { 227*fcf3ce44SJohn Forte t = time(NULL); 228*fcf3ce44SJohn Forte c = clock(); 229*fcf3ce44SJohn Forte } 230*fcf3ce44SJohn Forte #endif 231*fcf3ce44SJohn Forte status = TARGET_func(_update_retreat)(); 232*fcf3ce44SJohn Forte #ifdef DEBUG 233*fcf3ce44SJohn Forte if (verbose_tc != 0) { 234*fcf3ce44SJohn Forte t = time(NULL) - t; 235*fcf3ce44SJohn Forte c = clock() - c; 236*fcf3ce44SJohn Forte total_time += t; 237*fcf3ce44SJohn Forte total_clock += c; 238*fcf3ce44SJohn Forte printf("time %d clock %.4lf -flushing the data\n", 239*fcf3ce44SJohn Forte t, c / (double)CLOCKS_PER_SEC); 240*fcf3ce44SJohn Forte printf("time %d clock %.4lf -total update\n", 241*fcf3ce44SJohn Forte total_time, total_clock / (double)CLOCKS_PER_SEC); 242*fcf3ce44SJohn Forte total_time = 0; 243*fcf3ce44SJohn Forte total_clock = 0; 244*fcf3ce44SJohn Forte } 245*fcf3ce44SJohn Forte #endif 246*fcf3ce44SJohn Forte return (status); 247*fcf3ce44SJohn Forte } 248