zinject.c (225736) | zinject.c (243674) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 283 unchanged lines hidden (view full) --- 292 "\t\t\tspacemap, metaslab, errlog. The only valid <object> is\n" 293 "\t\t\tthe poolname.\n"); 294} 295 296static int 297iter_handlers(int (*func)(int, const char *, zinject_record_t *, void *), 298 void *data) 299{ | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 283 unchanged lines hidden (view full) --- 292 "\t\t\tspacemap, metaslab, errlog. The only valid <object> is\n" 293 "\t\t\tthe poolname.\n"); 294} 295 296static int 297iter_handlers(int (*func)(int, const char *, zinject_record_t *, void *), 298 void *data) 299{ |
300 zfs_cmd_t zc; | 300 zfs_cmd_t zc = { 0 }; |
301 int ret; 302 | 301 int ret; 302 |
303 zc.zc_guid = 0; 304 | |
305 while (ioctl(zfs_fd, ZFS_IOC_INJECT_LIST_NEXT, &zc) == 0) 306 if ((ret = func((int)zc.zc_guid, zc.zc_name, 307 &zc.zc_inject_record, data)) != 0) 308 return (ret); 309 310 if (errno != ENOENT) { 311 (void) fprintf(stderr, "Unable to list handlers: %s\n", 312 strerror(errno)); --- 106 unchanged lines hidden (view full) --- 419 return (count + total); 420} 421 422/* ARGSUSED */ 423static int 424cancel_one_handler(int id, const char *pool, zinject_record_t *record, 425 void *data) 426{ | 303 while (ioctl(zfs_fd, ZFS_IOC_INJECT_LIST_NEXT, &zc) == 0) 304 if ((ret = func((int)zc.zc_guid, zc.zc_name, 305 &zc.zc_inject_record, data)) != 0) 306 return (ret); 307 308 if (errno != ENOENT) { 309 (void) fprintf(stderr, "Unable to list handlers: %s\n", 310 strerror(errno)); --- 106 unchanged lines hidden (view full) --- 417 return (count + total); 418} 419 420/* ARGSUSED */ 421static int 422cancel_one_handler(int id, const char *pool, zinject_record_t *record, 423 void *data) 424{ |
427 zfs_cmd_t zc; | 425 zfs_cmd_t zc = { 0 }; |
428 429 zc.zc_guid = (uint64_t)id; 430 431 if (ioctl(zfs_fd, ZFS_IOC_CLEAR_FAULT, &zc) != 0) { 432 (void) fprintf(stderr, "failed to remove handler %d: %s\n", 433 id, strerror(errno)); 434 return (1); 435 } --- 16 unchanged lines hidden (view full) --- 452} 453 454/* 455 * Remove a specific fault injection handler. 456 */ 457static int 458cancel_handler(int id) 459{ | 426 427 zc.zc_guid = (uint64_t)id; 428 429 if (ioctl(zfs_fd, ZFS_IOC_CLEAR_FAULT, &zc) != 0) { 430 (void) fprintf(stderr, "failed to remove handler %d: %s\n", 431 id, strerror(errno)); 432 return (1); 433 } --- 16 unchanged lines hidden (view full) --- 450} 451 452/* 453 * Remove a specific fault injection handler. 454 */ 455static int 456cancel_handler(int id) 457{ |
460 zfs_cmd_t zc; | 458 zfs_cmd_t zc = { 0 }; |
461 462 zc.zc_guid = (uint64_t)id; 463 464 if (ioctl(zfs_fd, ZFS_IOC_CLEAR_FAULT, &zc) != 0) { 465 (void) fprintf(stderr, "failed to remove handler %d: %s\n", 466 id, strerror(errno)); 467 return (1); 468 } --- 5 unchanged lines hidden (view full) --- 474 475/* 476 * Register a new fault injection handler. 477 */ 478static int 479register_handler(const char *pool, int flags, zinject_record_t *record, 480 int quiet) 481{ | 459 460 zc.zc_guid = (uint64_t)id; 461 462 if (ioctl(zfs_fd, ZFS_IOC_CLEAR_FAULT, &zc) != 0) { 463 (void) fprintf(stderr, "failed to remove handler %d: %s\n", 464 id, strerror(errno)); 465 return (1); 466 } --- 5 unchanged lines hidden (view full) --- 472 473/* 474 * Register a new fault injection handler. 475 */ 476static int 477register_handler(const char *pool, int flags, zinject_record_t *record, 478 int quiet) 479{ |
482 zfs_cmd_t zc; | 480 zfs_cmd_t zc = { 0 }; |
483 484 (void) strcpy(zc.zc_name, pool); 485 zc.zc_inject_record = *record; 486 zc.zc_guid = flags; 487 488 if (ioctl(zfs_fd, ZFS_IOC_INJECT_FAULT, &zc) != 0) { 489 (void) fprintf(stderr, "failed to add handler: %s\n", 490 strerror(errno)); --- 40 unchanged lines hidden (view full) --- 531 } 532 533 return (0); 534} 535 536int 537perform_action(const char *pool, zinject_record_t *record, int cmd) 538{ | 481 482 (void) strcpy(zc.zc_name, pool); 483 zc.zc_inject_record = *record; 484 zc.zc_guid = flags; 485 486 if (ioctl(zfs_fd, ZFS_IOC_INJECT_FAULT, &zc) != 0) { 487 (void) fprintf(stderr, "failed to add handler: %s\n", 488 strerror(errno)); --- 40 unchanged lines hidden (view full) --- 529 } 530 531 return (0); 532} 533 534int 535perform_action(const char *pool, zinject_record_t *record, int cmd) 536{ |
539 zfs_cmd_t zc; | 537 zfs_cmd_t zc = { 0 }; |
540 541 ASSERT(cmd == VDEV_STATE_DEGRADED || cmd == VDEV_STATE_FAULTED); 542 (void) strlcpy(zc.zc_name, pool, sizeof (zc.zc_name)); 543 zc.zc_guid = record->zi_guid; 544 zc.zc_cookie = cmd; 545 546 if (ioctl(zfs_fd, ZFS_IOC_VDEV_SET_STATE, &zc) == 0) 547 return (0); --- 428 unchanged lines hidden --- | 538 539 ASSERT(cmd == VDEV_STATE_DEGRADED || cmd == VDEV_STATE_FAULTED); 540 (void) strlcpy(zc.zc_name, pool, sizeof (zc.zc_name)); 541 zc.zc_guid = record->zi_guid; 542 zc.zc_cookie = cmd; 543 544 if (ioctl(zfs_fd, ZFS_IOC_VDEV_SET_STATE, &zc) == 0) 545 return (0); --- 428 unchanged lines hidden --- |