-
Notifications
You must be signed in to change notification settings - Fork 0
/
ibp_sync.c
293 lines (232 loc) · 9.53 KB
/
ibp_sync.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
/*
Advanced Computing Center for Research and Education Proprietary License
Version 1.0 (April 2006)
Copyright (c) 2006, Advanced Computing Center for Research and Education,
Vanderbilt University, All rights reserved.
This Work is the sole and exclusive property of the Advanced Computing Center
for Research and Education department at Vanderbilt University. No right to
disclose or otherwise disseminate any of the information contained herein is
granted by virtue of your possession of this software except in accordance with
the terms and conditions of a separate License Agreement entered into with
Vanderbilt University.
THE AUTHOR OR COPYRIGHT HOLDERS PROVIDES THE "WORK" ON AN "AS IS" BASIS,
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, TITLE, FITNESS FOR A PARTICULAR
PURPOSE, AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Vanderbilt University
Advanced Computing Center for Research and Education
230 Appleton Place
Nashville, TN 37203
http://www.accre.vanderbilt.edu
*/
#include <stdlib.h>
#include <assert.h>
#include "ibp.h"
#include "host_portal.h"
#include "log.h"
//**************************************************************************
//--------------- Unsupported routines are listed below -------------------
//**************************************************************************
#ifndef IBP_REMOVE_UNSUPPORTED
unsigned long int IBP_mcopy ( IBP_cap pc_SourceCap,
IBP_cap pc_TargetCap[],
unsigned int pi_CapCnt,
IBP_timer ps_src_timeout,
IBP_timer ps_tgt_timeout,
unsigned long int pl_size,
unsigned long int pl_offset,
int dm_type[],
int dm_port[],
int dm_service)
{
IBP_errno = IBP_E_TYPE_NOT_SUPPORTED;
return(0);
}
unsigned long int IBP_datamover ( IBP_cap pc_TargetCap,
IBP_cap pc_ReadCap,
IBP_timer ps_tgt_timeout,
unsigned long int pl_size,
unsigned long int pl_offset,
int dm_type,
int dm_port,
int dm_service)
{
IBP_errno = IBP_E_TYPE_NOT_SUPPORTED;
return(0);
}
int IBP_setAuthenAttribute(char *certFile, char *privateKeyFile , char *passwd)
{
IBP_errno = IBP_E_TYPE_NOT_SUPPORTED;
return(0);
}
int IBP_freeCapSet(IBP_set_of_caps capSet)
{
IBP_errno = IBP_E_TYPE_NOT_SUPPORTED;
return(0);
}
char* DM_Array2String(int numelems, void *array[], int type)
{
IBP_errno = IBP_E_TYPE_NOT_SUPPORTED;
return(NULL);
}
int IBP_setMaxOpenConn(int max)
{
IBP_errno = IBP_E_TYPE_NOT_SUPPORTED;
return(0);
}
#endif
//**************************************************************************
// ------------------ Supported routines are given below -------------------
//**************************************************************************
//**************************************************************************
// ibp_sync_command - Executes a command synchronously
//**************************************************************************
int ibp_sync_command(ibp_op_t *op) {
oplist_t oplist;
init_ibp_oplist(&oplist, NULL);
add_ibp_oplist(&oplist, op);
submit_hportal_sync(_hpc_config, &oplist, (void *)op);
//int dummy = oplist_waitall(&oplist);
//IBP_errno= dummy;
//log_printf(20, "ibp_sync_command: errno=%d dummy=%d\n", dummy, IBP_errno);
IBP_errno = oplist_waitall(&oplist);
finalize_oplist(&oplist, 1);
return(IBP_errno);
}
//**************************************************************************
// IBP_allocate - Creates an allocation and Returns a set of capabilities
//**************************************************************************
ibp_capset_t *IBP_allocate(ibp_depot_t *depot, ibp_timer_t *timer, unsigned long int size, ibp_attributes_t *attr)
{
ibp_op_t op;
int err;
ibp_capset_t *cs = (ibp_capset_t *)malloc(sizeof(ibp_capset_t));
assert(cs != NULL);
set_ibp_alloc_op(&op, cs, size, depot, attr, timer->ClientTimeout, NULL, NULL);
err = ibp_sync_command(&op);
if (err != IBP_OK) {free(cs); cs = NULL; }
return(cs);
}
//**************************************************************************
// IBP_write - Stores dataa at the given offset for an IBP allocation
//**************************************************************************
unsigned long int IBP_write(ibp_cap_t *cap, ibp_timer_t *timer, char *data,
unsigned long int size, unsigned long int offset)
{
ibp_op_t op;
int err;
set_ibp_write_op(&op, cap, offset, size, data, timer->ClientTimeout, NULL, NULL);
err = ibp_sync_command(&op);
if (err != IBP_OK) return(0);
return(size);
}
//**************************************************************************
// IBP_store - *Appends* data to an IBP allocation
//**************************************************************************
unsigned long int IBP_store(ibp_cap_t *cap, ibp_timer_t *timer, char *data,
unsigned long int size)
{
ibp_op_t op;
int err;
set_ibp_append_op(&op, cap, size, data, timer->ClientTimeout, NULL, NULL);
err = ibp_sync_command(&op);
if (err != IBP_OK) return(0);
return(size);
}
//**************************************************************************
// IBP_load - Reads data from the given IBP allocation
//**************************************************************************
unsigned long int IBP_load(ibp_cap_t *cap, ibp_timer_t *timer, char *data,
unsigned long int size, unsigned long int offset)
{
ibp_op_t op;
int err;
set_ibp_read_op(&op, cap, offset, size, data, timer->ClientTimeout, NULL, NULL);
err = ibp_sync_command(&op);
if (err != IBP_OK) return(0);
return(size);
}
//**************************************************************************
// IBP_copy - Copies data between allocations. The data is *appended* to the
// end of the destination allocation.
//**************************************************************************
unsigned long int IBP_copy(ibp_cap_t *srccap, ibp_cap_t *destcap, ibp_timer_t *src_timer, ibp_timer_t *dest_timer,
unsigned long int size, unsigned long int offset)
{
ibp_op_t op;
int err;
set_ibp_copyappend_op(&op, NS_TYPE_SOCK, NULL, srccap, destcap, offset, size, src_timer->ClientTimeout,
dest_timer->ServerSync, dest_timer->ClientTimeout, NULL, NULL);
err = ibp_sync_command(&op);
if (err != IBP_OK) return(0);
return(size);
}
//**************************************************************************
// IBP_copy - Copies data between allocations. The data is *appended* to the
// end of the destination allocation.
//**************************************************************************
unsigned long int IBP_phoebus_copy(char *path, ibp_cap_t *srccap, ibp_cap_t *destcap, ibp_timer_t *src_timer, ibp_timer_t *dest_timer,
unsigned long int size, unsigned long int offset)
{
ibp_op_t op;
int err;
set_ibp_copyappend_op(&op, NS_TYPE_PHOEBUS, path, srccap, destcap, offset, size, src_timer->ClientTimeout,
dest_timer->ServerSync, dest_timer->ClientTimeout, NULL, NULL);
err = ibp_sync_command(&op);
if (err != IBP_OK) return(0);
return(size);
}
//**************************************************************************
// IBP_manage - Queries/modifies an IBP allocations properties
//**************************************************************************
int IBP_manage(ibp_cap_t *cap, ibp_timer_t *timer, int cmd, int captype, ibp_capstatus_t *cs)
{
ibp_op_t op;
int err;
err = 0;
switch (cmd) {
case IBP_INCR:
case IBP_DECR:
set_ibp_modify_count_op(&op, cap, cmd, captype, timer->ClientTimeout, NULL, NULL);
break;
case IBP_PROBE:
set_ibp_probe_op(&op, cap, cs, timer->ClientTimeout, NULL, NULL);
break;
case IBP_CHNG:
set_ibp_modify_alloc_op(&op, cap, cs->maxSize, cs->attrib.duration, cs->attrib.reliability, timer->ClientTimeout, NULL, NULL);
break;
default:
err = 1;
log_printf(0, "IBP_manage: Invalid command: %d\n", cmd);
}
if (err == 0) {
err = ibp_sync_command(&op);
} else {
IBP_errno = IBP_E_INVALID_PARAMETER;
}
if (IBP_errno != IBP_OK) return(-1);
return(0);
}
//**************************************************************************
// IBP_status - Reads data from the given IBP allocation
//**************************************************************************
ibp_depotinfo_t *IBP_status(ibp_depot_t *depot, int cmd, ibp_timer_t *timer, char *password,
unsigned long int hard, unsigned long int soft, long duration)
{
int err;
ibp_op_t op;
ibp_depotinfo_t *di = NULL;
if (cmd == IBP_ST_INQ) {
di = (ibp_depotinfo_t *)malloc(sizeof(ibp_depotinfo_t));
assert(di != NULL);
set_ibp_depot_inq_op(&op, depot, password, di, timer->ClientTimeout, NULL, NULL);
} else {
set_ibp_depot_modify_op(&op, depot, password, hard, soft, duration, timer->ClientTimeout, NULL, NULL);
}
err = ibp_sync_command(&op);
if (err != IBP_OK) { free(di); return(NULL); }
return(di);
}