glusterfs

Форк
0
/
glfs-lease.c 
717 строк · 18.3 Кб
1
#include <glusterfs/api/glfs.h>
2
#include <glusterfs/api/glfs-handles.h>
3
#include <errno.h>
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <string.h>
7
#include <fcntl.h>
8
#include <sys/stat.h>
9

10
/* Few rules:
11
 * 1. A client may have multiple lease keys, but a lease key cannot be shared by
12
 * multiple clients.
13
 * 2. Lease key can be set before open, or in glfs_lease request. A lease key
14
 * set like this is valid for the lifetime of the fd, i.e. a fd cannot have
15
 * multiple lease key. But a lease key can be shared across multiple fds.
16
 */
17
glfs_t *client1 = NULL, *client2 = NULL, *client3 = NULL, *client4 = NULL;
18
glfs_fd_t *fd1 = NULL, *fd2 = NULL, *fd3 = NULL, *fd4 = NULL;
19
FILE *log_file = NULL;
20
char lid1[GLFS_LEASE_ID_SIZE] = "lid1-clnt1",
21
     lid2[GLFS_LEASE_ID_SIZE] = "lid2-clnt2";
22
char lid3[GLFS_LEASE_ID_SIZE] = "lid3-clnt2", lid4[GLFS_LEASE_ID_SIZE] = {
23
                                                  0,
24
};
25
char *volname = NULL, *glfs_log_file = NULL;
26

27
#define MAX_CLIENTS 4
28
#define MAX_FDS 4
29
#define TEST_FILE "/test/lease"
30
#define SHUD_PASS 0
31
#define SHUD_FAIL -1
32
#define NONE 0
33

34
static void
35
recall_cbk(struct glfs_lease lease, void *data);
36

37
static int
38
set_read_lease(glfs_fd_t *fd, char ld[])
39
{
40
    struct glfs_lease lease = {
41
        0,
42
    };
43
    int ret = 0;
44

45
    memset(&lease, 0, sizeof(lease));
46
    lease.cmd = GLFS_SET_LEASE;
47
    lease.lease_type = GLFS_RD_LEASE;
48
    memcpy(&lease.lease_id, ld, GLFS_LEASE_ID_SIZE);
49
    ret = glfs_lease(fd, &lease, &recall_cbk, fd);
50
    if (ret < 0) {
51
        fprintf(log_file, "\n    RD_LEASE failed with ret: %d (%s)", ret,
52
                strerror(errno));
53
        return -1;
54
    }
55
    fprintf(log_file, "\n    Took RD_LEASE");
56
    return ret;
57
}
58

59
static int
60
set_write_lease(glfs_fd_t *fd, char ld[])
61
{
62
    struct glfs_lease lease = {
63
        0,
64
    };
65
    int ret = 0;
66

67
    memset(&lease, 0, sizeof(lease));
68
    lease.cmd = GLFS_SET_LEASE;
69
    lease.lease_type = GLFS_RW_LEASE;
70
    memcpy(&lease.lease_id, ld, GLFS_LEASE_ID_SIZE);
71
    ret = glfs_lease(fd, &lease, &recall_cbk, NULL);
72
    if (ret < 0) {
73
        fprintf(log_file, "\n    RW_LEASE failed with ret: %d (%s)", ret,
74
                strerror(errno));
75
        return -1;
76
    }
77
    fprintf(log_file, "\n    Took RW_LEASE");
78
    return ret;
79
}
80

81
static int
82
get_lease(glfs_fd_t *fd, char ld[])
83
{
84
    struct glfs_lease lease = {
85
        0,
86
    };
87
    int ret = 0;
88

89
    memset(&lease, 0, sizeof(lease));
90
    lease.cmd = GLFS_GET_LEASE;
91
    lease.lease_type = -1;
92
    memcpy(&lease.lease_id, ld, GLFS_LEASE_ID_SIZE);
93
    ret = glfs_lease(fd, &lease, &recall_cbk, NULL);
94
    if (ret < 0) {
95
        fprintf(log_file, "\n    GET_LEASE failed with ret: %d (%s)", ret,
96
                strerror(errno));
97
        return -1;
98
    }
99
    if (lease.lease_type == GLFS_RD_LEASE)
100
        fprintf(log_file, "\n    Esisting Lease: RD_LEASE");
101
    else if (lease.lease_type == GLFS_RW_LEASE)
102
        fprintf(log_file, "\n    Esisting Lease: RW_LEASE");
103
    else if (lease.lease_type == 3)
104
        fprintf(log_file, "\n    Esisting Lease: RD_LEASE|RW_LEASE");
105
    else if (lease.lease_type == 0)
106
        fprintf(log_file, "\n    Esisting Lease: NONE");
107
    else
108
        fprintf(log_file, "\n    Existing lease type:%d", lease.lease_type);
109
    return lease.lease_type;
110
}
111

112
static int
113
unlk_write_lease(glfs_fd_t *fd, char ld[])
114
{
115
    struct glfs_lease lease = {
116
        0,
117
    };
118
    int ret = 0;
119

120
    memset(&lease, 0, sizeof(lease));
121
    lease.cmd = GLFS_UNLK_LEASE;
122
    lease.lease_type = GLFS_RW_LEASE;
123
    memcpy(&lease.lease_id, ld, GLFS_LEASE_ID_SIZE);
124
    ret = glfs_lease(fd, &lease, &recall_cbk, NULL);
125
    if (ret < 0) {
126
        fprintf(log_file, "\n    Unlock RW_LESAE failed with ret: %d (%s)", ret,
127
                strerror(errno));
128
        return -1;
129
    }
130
    fprintf(log_file, "\n    Unlocked RW_LEASE");
131
    return ret;
132
}
133

134
static int
135
unlk_read_lease(glfs_fd_t *fd, char ld[])
136
{
137
    struct glfs_lease lease = {
138
        0,
139
    };
140
    int ret = 0;
141

142
    memset(&lease, 0, sizeof(lease));
143
    lease.cmd = GLFS_UNLK_LEASE;
144
    lease.lease_type = GLFS_RD_LEASE;
145
    memcpy(&lease.lease_id, ld, GLFS_LEASE_ID_SIZE);
146

147
    ret = glfs_lease(fd, &lease, &recall_cbk, NULL);
148
    if (ret < 0) {
149
        fprintf(log_file, "\n    Unlock RD_LEASE failed with ret: %d (%s)", ret,
150
                strerror(errno));
151
        return -1;
152
    }
153
    fprintf(log_file, "\n    Unlocked RD_LEASE");
154
    return ret;
155
}
156

157
glfs_t *
158
setup_new_client(char *volname, char *log_fileile)
159
{
160
    int ret = 0;
161
    glfs_t *fs = NULL;
162

163
    fs = glfs_new(volname);
164
    if (!fs) {
165
        fprintf(log_file, "\nglfs_new: returned NULL (%s)\n", strerror(errno));
166
        goto error;
167
    }
168

169
    ret = glfs_set_volfile_server(fs, "tcp", "localhost", 24007);
170
    if (ret < 0) {
171
        fprintf(log_file, "\nglfs_set_volfile_server failed ret:%d (%s)\n", ret,
172
                strerror(errno));
173
        goto error;
174
    }
175

176
    ret = glfs_set_logging(fs, log_fileile, 7);
177
    if (ret < 0) {
178
        fprintf(log_file, "\nglfs_set_logging failed with ret: %d (%s)\n", ret,
179
                strerror(errno));
180
        goto error;
181
    }
182

183
    ret = glfs_init(fs);
184
    if (ret < 0) {
185
        fprintf(log_file, "\nglfs_init failed with ret: %d (%s)\n", ret,
186
                strerror(errno));
187
        goto error;
188
    }
189
    return fs;
190
error:
191
    return NULL;
192
}
193

194
#define OPEN(client, flags, fd, lease_id)                                      \
195
    do {                                                                       \
196
        int ret_val = 0;                                                       \
197
        ret_val = glfs_setfsleaseid(lease_id);                                 \
198
        if (ret_val) {                                                         \
199
            fprintf(log_file,                                                  \
200
                    "\nglfs_setfsleaseid failed with ret: %d (%s)\n", ret,     \
201
                    strerror(errno));                                          \
202
            return -1;                                                         \
203
        }                                                                      \
204
        fd = glfs_open(client, TEST_FILE, flags);                              \
205
        if (fd == NULL) {                                                      \
206
            fprintf(log_file, "\nglfs_open failed with ret: %d (%s)\n", ret,   \
207
                    strerror(errno));                                          \
208
            return -1;                                                         \
209
        }                                                                      \
210
    } while (0)
211

212
#define VERIFY_RESULT(test_case, ret, value)                                   \
213
    do {                                                                       \
214
        if (ret != value) {                                                    \
215
            fprintf(log_file,                                                  \
216
                    "\n    Testcase %d failed, ret = %d, value=%d\n",          \
217
                    test_case, ret, value);                                    \
218
            goto error; /*test unsuccessful*/                                  \
219
        }                                                                      \
220
        fprintf(log_file, "\n    Testcase %d Succeeded\n", test_case);         \
221
    } while (0)
222

223
static void
224
recall_cbk(struct glfs_lease lease, void *data)
225
{
226
    int ret = -1;
227
    char ld[GLFS_LEASE_ID_SIZE] = "";
228

229
    fprintf(log_file, "\nRECALL received on lease_id:(%s)", lease.lease_id);
230
    memcpy(ld, lease.lease_id, GLFS_LEASE_ID_SIZE);
231
    ret = unlk_write_lease((glfs_fd_t *)data, ld);
232
    VERIFY_RESULT(500, ret, SHUD_PASS);
233
error:
234
    return;
235
}
236

237
static int
238
testcase1_rd_lease()
239
{
240
    glfs_fd_t *fd1 = NULL;
241
    int ret = 0;
242

243
    fprintf(log_file, "\n Basic test case for Read lease:");
244
    /* Open fd on client 1 in RD mode */
245
    OPEN(client1, O_RDONLY, fd1, lid1);
246
    ret = set_write_lease(fd1, lid1);
247
    VERIFY_RESULT(1, ret, SHUD_FAIL);
248

249
    ret = set_read_lease(fd1, lid1);
250
    VERIFY_RESULT(2, ret, SHUD_PASS);
251

252
    ret = get_lease(fd1, lid1);
253
    VERIFY_RESULT(3, ret, GLFS_RD_LEASE);
254

255
    ret = unlk_write_lease(fd1, lid1);
256
    VERIFY_RESULT(4, ret, SHUD_FAIL);
257

258
    ret = unlk_read_lease(fd1, lid1);
259
    VERIFY_RESULT(5, ret, SHUD_PASS);
260

261
    ret = get_lease(fd1, lid1);
262
    VERIFY_RESULT(6, ret, NONE);
263

264
    ret = unlk_read_lease(fd1, lid1);
265
    VERIFY_RESULT(7, ret, SHUD_PASS);
266

267
    ret = glfs_close(fd1);
268
    VERIFY_RESULT(8, ret, SHUD_PASS);
269

270
    return 0;
271
error:
272
    return -1;
273
}
274

275
static int
276
testcase2_wr_lease()
277
{
278
    glfs_fd_t *fd1 = NULL;
279
    int ret = 0;
280

281
    fprintf(log_file, "\n Basic test case for Write lease:");
282
    /* Open fd on client 1 in WRonly mode */
283
    OPEN(client1, O_WRONLY, fd1, lid1);
284
    ret = set_read_lease(fd1, lid1);
285
    VERIFY_RESULT(1, ret, SHUD_FAIL);
286

287
    ret = unlk_write_lease(fd1, lid1);
288
    VERIFY_RESULT(2, ret, SHUD_PASS);
289

290
    ret = set_write_lease(fd1, lid1);
291
    VERIFY_RESULT(3, ret, SHUD_PASS);
292

293
    ret = get_lease(fd1, lid1);
294
    VERIFY_RESULT(4, ret, GLFS_RW_LEASE);
295

296
    ret = unlk_write_lease(fd1, lid1);
297
    VERIFY_RESULT(5, ret, SHUD_PASS);
298

299
    ret = get_lease(fd1, lid1);
300
    VERIFY_RESULT(6, ret, NONE);
301

302
    ret = unlk_read_lease(fd1, lid1);
303
    VERIFY_RESULT(7, ret, SHUD_FAIL);
304

305
    ret = glfs_close(fd1);
306
    VERIFY_RESULT(8, ret, SHUD_PASS);
307

308
    return 0;
309
error:
310
    return -1;
311
}
312

313
static int
314
testcase3_rd_wr_lease()
315
{
316
    glfs_fd_t *fd1 = NULL;
317
    int ret = 0;
318

319
    fprintf(log_file, "\n Basic test case for Read Write lease:");
320
    /* Open fd on client 1 in WRonly mode */
321
    OPEN(client1, O_RDWR, fd1, lid1);
322
    ret = set_read_lease(fd1, lid1);
323
    VERIFY_RESULT(1, ret, SHUD_PASS);
324

325
    ret = set_write_lease(fd1, lid1);
326
    VERIFY_RESULT(2, ret, SHUD_PASS);
327

328
    ret = get_lease(fd1, lid1);
329
    VERIFY_RESULT(3, ret, (GLFS_RW_LEASE | GLFS_RD_LEASE));
330

331
    ret = unlk_write_lease(fd1, lid1);
332
    VERIFY_RESULT(4, ret, SHUD_PASS);
333

334
    ret = get_lease(fd1, lid1);
335
    VERIFY_RESULT(5, ret, GLFS_RD_LEASE);
336

337
    ret = unlk_read_lease(fd1, lid1);
338
    VERIFY_RESULT(6, ret, SHUD_PASS);
339

340
    ret = get_lease(fd1, lid1);
341
    VERIFY_RESULT(7, ret, NONE);
342

343
    ret = glfs_close(fd1);
344
    VERIFY_RESULT(8, ret, SHUD_PASS);
345

346
    return 0;
347
error:
348
    return -1;
349
}
350

351
static int
352
testcase4_rd_lease_multi_clnt()
353
{
354
    glfs_fd_t *fd1 = NULL;
355
    glfs_fd_t *fd2 = NULL;
356
    int ret = 0;
357

358
    fprintf(log_file, "\n Basic test case for multi client Read lease:");
359

360
    /* Open fd on client 1 in RD mode */
361
    OPEN(client1, O_RDONLY, fd1, lid1);
362

363
    /* Open fd on client 2 in RW mode */
364
    OPEN(client2, O_RDONLY, fd2, lid2);
365

366
    ret = set_read_lease(fd1, lid1);
367
    VERIFY_RESULT(1, ret, SHUD_PASS);
368

369
    ret = set_read_lease(fd2, lid2);
370
    VERIFY_RESULT(2, ret, SHUD_PASS);
371

372
    ret = get_lease(fd1, lid1);
373
    VERIFY_RESULT(3, ret, GLFS_RD_LEASE);
374

375
    ret = unlk_read_lease(fd1, lid1);
376
    VERIFY_RESULT(4, ret, SHUD_PASS);
377

378
    ret = unlk_read_lease(fd2, lid2);
379
    VERIFY_RESULT(5, ret, SHUD_PASS);
380

381
    ret = get_lease(fd1, lid1);
382
    VERIFY_RESULT(6, ret, NONE);
383

384
    ret = get_lease(fd2, lid2);
385
    VERIFY_RESULT(7, ret, NONE);
386

387
    ret = glfs_close(fd1);
388
    VERIFY_RESULT(8, ret, SHUD_PASS);
389

390
    ret = glfs_close(fd2);
391
    VERIFY_RESULT(9, ret, SHUD_PASS);
392

393
    return 0;
394
error:
395
    return -1;
396
}
397

398
static int
399
testcase5_openfd_multi_lid()
400
{
401
    glfs_fd_t *fd1 = NULL;
402
    glfs_fd_t *fd2 = NULL;
403
    glfs_fd_t *fd3 = NULL;
404
    int ret = 0;
405

406
    fprintf(log_file, "\n Basic test case for multi lid openfd check:");
407

408
    /* Open fd on client 1 in RD mode */
409
    OPEN(client1, O_RDONLY, fd1, lid1);
410

411
    /* Open fd on client 2 in RW mode */
412
    OPEN(client2, O_RDWR, fd2, lid2);
413
    OPEN(client2, O_RDWR, fd3, lid2);
414

415
    ret = set_read_lease(fd1, lid1);
416
    VERIFY_RESULT(
417
        1, ret,
418
        SHUD_FAIL); /*As there are other openfds in WR mode from diff lid*/
419

420
    ret = set_write_lease(fd2, lid2);
421
    VERIFY_RESULT(
422
        2, ret, SHUD_FAIL); /*As thers is another fd in RD mode from diff lid */
423

424
    ret = glfs_close(fd1);
425
    VERIFY_RESULT(3, ret, SHUD_PASS);
426

427
    ret = set_write_lease(fd2, lid2);
428
    VERIFY_RESULT(4, ret, SHUD_PASS);
429

430
    ret = unlk_write_lease(fd2, lid2);
431
    VERIFY_RESULT(5, ret, SHUD_PASS);
432

433
    ret = glfs_close(fd2);
434
    VERIFY_RESULT(6, ret, SHUD_PASS);
435

436
    ret = glfs_close(fd3);
437
    VERIFY_RESULT(7, ret, SHUD_PASS);
438

439
    return 0;
440
error:
441
    return -1;
442
}
443

444
static int
445
testcase6_openfd_same_lid()
446
{
447
    glfs_fd_t *fd1 = NULL;
448
    glfs_fd_t *fd2 = NULL;
449
    glfs_fd_t *fd3 = NULL;
450
    int ret = 0;
451

452
    fprintf(log_file, "\n Basic test case for same lid openfd check:");
453

454
    /* Open fd on client 2 in RW mode */
455
    OPEN(client1, O_RDWR, fd1, lid2);
456
    OPEN(client1, O_RDWR, fd2, lid2);
457

458
    ret = set_write_lease(fd1, lid2);
459
    VERIFY_RESULT(4, ret, SHUD_PASS);
460

461
    ret = set_write_lease(fd2, lid2);
462
    VERIFY_RESULT(4, ret, SHUD_PASS);
463

464
    ret = set_read_lease(fd2, lid2);
465
    VERIFY_RESULT(4, ret, SHUD_PASS);
466

467
    ret = unlk_write_lease(fd1, lid2);
468
    VERIFY_RESULT(5, ret, SHUD_PASS);
469

470
    ret = unlk_read_lease(fd2, lid2);
471
    VERIFY_RESULT(5, ret, SHUD_PASS);
472

473
    ret = unlk_write_lease(fd2, lid2);
474
    VERIFY_RESULT(5, ret, SHUD_PASS);
475

476
    ret = glfs_close(fd1);
477
    VERIFY_RESULT(6, ret, SHUD_PASS);
478

479
    ret = glfs_close(fd2);
480
    VERIFY_RESULT(7, ret, SHUD_PASS);
481

482
    return 0;
483
error:
484
    return -1;
485
}
486

487
static int
488
testcase7_rd_multi_lid()
489
{
490
    glfs_fd_t *fd1 = NULL;
491
    glfs_fd_t *fd2 = NULL;
492
    int ret = 0;
493

494
    fprintf(log_file, "\n Basic test case for multi lease id Read lease:");
495

496
    /* Open fd on client 1 in RD mode */
497
    OPEN(client2, O_RDONLY, fd1, lid2);
498

499
    /* Open fd on client 2 in RD mode */
500
    OPEN(client2, O_RDONLY, fd2, lid3);
501

502
    ret = set_read_lease(fd1, lid2);
503
    VERIFY_RESULT(1, ret, SHUD_PASS);
504

505
    ret = set_read_lease(fd2, lid3);
506
    VERIFY_RESULT(2, ret, SHUD_PASS);
507

508
    ret = get_lease(fd1, lid2);
509
    VERIFY_RESULT(3, ret, GLFS_RD_LEASE);
510

511
    ret = unlk_read_lease(fd1, lid2);
512
    VERIFY_RESULT(4, ret, SHUD_PASS);
513

514
    ret = unlk_read_lease(fd2, lid3);
515
    VERIFY_RESULT(5, ret, SHUD_PASS);
516

517
    ret = get_lease(fd1, lid2);
518
    VERIFY_RESULT(6, ret, NONE);
519

520
    ret = get_lease(fd2, lid3);
521
    VERIFY_RESULT(7, ret, NONE);
522

523
    ret = glfs_close(fd1);
524
    VERIFY_RESULT(8, ret, SHUD_PASS);
525

526
    ret = glfs_close(fd2);
527
    VERIFY_RESULT(9, ret, SHUD_PASS);
528

529
    return 0;
530
error:
531
    return -1;
532
}
533

534
static int
535
testcase8_client_disconnect()
536
{
537
    glfs_fd_t *fd1 = NULL;
538
    glfs_fd_t *fd2 = NULL;
539
    int ret = 0;
540

541
    fprintf(log_file, "\n Basic test case for client disconnect cleanup");
542

543
    /* Open fd on client 1 in RD mode */
544
    OPEN(client1, O_RDWR, fd1, lid1);
545

546
    ret = set_read_lease(fd1, lid1);
547
    VERIFY_RESULT(1, ret, SHUD_PASS);
548

549
    ret = get_lease(fd1, lid1);
550
    VERIFY_RESULT(2, ret, GLFS_RD_LEASE);
551

552
    ret = set_write_lease(fd1, lid1);
553
    VERIFY_RESULT(3, ret, SHUD_PASS);
554

555
    ret = get_lease(fd1, lid1);
556
    VERIFY_RESULT(4, ret, (GLFS_RD_LEASE | GLFS_RW_LEASE));
557

558
    ret = glfs_fini(client1);
559
    VERIFY_RESULT(5, ret, SHUD_PASS);
560

561
    /* Open fd on client 2 in RD mode */
562
    OPEN(client2, O_RDONLY, fd2, lid3);
563

564
    ret = get_lease(fd2, lid3);
565
    VERIFY_RESULT(6, ret, NONE);
566

567
    ret = glfs_close(fd2);
568
    VERIFY_RESULT(7, ret, SHUD_PASS);
569

570
    client1 = setup_new_client(volname, glfs_log_file);
571

572
    return 0;
573
error:
574
    return -1;
575
}
576

577
static int
578
testcase9_recall_conflict_lease()
579
{
580
    struct glfs_object *obj = NULL;
581
    glfs_fd_t *fd1 = NULL;
582
    int ret = 0;
583
    struct glfs_lease lease = {
584
        0,
585
    };
586

587
    fprintf(log_file,
588
            "\n Basic test case for conflicting lease causing recall");
589

590
    memset(&lease, 0, sizeof(lease));
591
    lease.cmd = GLFS_SET_LEASE;
592
    lease.lease_type = GLFS_RD_LEASE;
593
    memcpy(&lease.lease_id, lid2, GLFS_LEASE_ID_SIZE);
594
    /* Open fd on client 1 in RD mode */
595
    OPEN(client1, O_RDWR, fd1, lid1);
596
    ret = set_write_lease(fd1, lid1);
597
    VERIFY_RESULT(1, ret, SHUD_PASS);
598

599
    obj = glfs_h_lookupat(client2, NULL, TEST_FILE, NULL, 0);
600
    ret = glfs_h_lease(client2, obj, &lease);
601
    VERIFY_RESULT(2, ret, SHUD_FAIL);
602

603
    ret = unlk_write_lease(fd1, lid1);
604
    VERIFY_RESULT(5, ret, SHUD_PASS);
605

606
    sleep(3);
607
    ret = glfs_h_close(obj);
608
    VERIFY_RESULT(3, ret, SHUD_PASS);
609
    ret = glfs_close(fd1);
610
    VERIFY_RESULT(4, ret, SHUD_PASS);
611

612
    return 0;
613
error:
614
    return -1;
615
}
616

617
static int
618
testcase10_recall_open_conflict()
619
{
620
    glfs_fd_t *fd1 = NULL;
621
    glfs_fd_t *fd2 = NULL;
622
    int ret = 0;
623

624
    fprintf(log_file, "\n Basic test case for conflicting open causing recall");
625

626
    /* Open fd on client 1 in RW mode */
627
    OPEN(client1, O_RDWR, fd1, lid1);
628

629
    ret = set_write_lease(fd1, lid1);
630
    VERIFY_RESULT(1, ret, SHUD_PASS);
631

632
    /* Open fd on client 1 in RW mode */
633
    OPEN(client2, O_RDWR, fd2, lid2);
634

635
    /* TODO: Check for recall cbk functionality */
636
    ret = glfs_close(fd1);
637
    VERIFY_RESULT(2, ret, SHUD_PASS);
638

639
    ret = glfs_close(fd2);
640
    VERIFY_RESULT(3, ret, SHUD_PASS);
641

642
    return 0;
643
error:
644
    return -1;
645
}
646

647
int
648
main(int argc, char *argv[])
649
{
650
    int ret = 0;
651
    int i = 0;
652
    glfs_fd_t *fd = NULL;
653
    glfs_fd_t *fd1 = NULL;
654
    char *topdir = "topdir", *filename = "file1";
655
    char *buf = NULL;
656
    int x = 0;
657
    ssize_t xattr_size = -1;
658

659
    if (argc != 4) {
660
        fprintf(stderr,
661
                "Expect following args %s <Vol> <glfs client log file> "
662
                "<testcase log file>\n",
663
                argv[0]);
664
        return -1;
665
    }
666

667
    log_file = fopen(argv[3], "w");
668
    if (!log_file)
669
        goto error;
670

671
    volname = argv[1];
672
    glfs_log_file = argv[2];
673

674
    /* Setup 3 clients */
675
    client1 = setup_new_client(volname, glfs_log_file);
676
    client2 = setup_new_client(volname, glfs_log_file);
677
    client3 = setup_new_client(volname, glfs_log_file);
678

679
    ret = testcase1_rd_lease();
680
    VERIFY_RESULT(101, ret, SHUD_PASS);
681

682
    ret = testcase2_wr_lease();
683
    VERIFY_RESULT(102, ret, SHUD_PASS);
684

685
    ret = testcase3_rd_wr_lease();
686
    VERIFY_RESULT(103, ret, SHUD_PASS);
687

688
    ret = testcase4_rd_lease_multi_clnt();
689
    VERIFY_RESULT(104, ret, SHUD_PASS);
690

691
    ret = testcase5_openfd_multi_lid();
692
    VERIFY_RESULT(105, ret, SHUD_PASS);
693

694
    ret = testcase6_openfd_same_lid();
695
    VERIFY_RESULT(106, ret, SHUD_PASS);
696

697
    ret = testcase7_rd_multi_lid();
698
    VERIFY_RESULT(107, ret, SHUD_PASS);
699

700
    ret = testcase8_client_disconnect();
701
    VERIFY_RESULT(108, ret, SHUD_PASS);
702

703
    ret = testcase9_recall_conflict_lease();
704
    VERIFY_RESULT(109, ret, SHUD_PASS);
705

706
    ret = testcase10_recall_open_conflict();
707
    VERIFY_RESULT(110, ret, SHUD_PASS);
708

709
    glfs_fini(client1);
710
    glfs_fini(client2);
711
    glfs_fini(client3);
712

713
    fclose(log_file);
714
    return 0;
715
error:
716
    return -1;
717
}
718

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.