| 713 | } |
| 714 | |
| 715 | void |
| 716 | CacheProcessor::diskInitialized() |
| 717 | { |
| 718 | int n_init = initialize_disk++; |
| 719 | int bad_disks = 0; |
| 720 | int res = 0; |
| 721 | int i; |
| 722 | |
| 723 | // Wait for all the cache disks are initialized |
| 724 | if (n_init != gndisks - 1) { |
| 725 | return; |
| 726 | } |
| 727 | |
| 728 | // Check and remove bad disks from gdisks[] |
| 729 | for (i = 0; i < gndisks; i++) { |
| 730 | if (DISK_BAD(gdisks[i])) { |
| 731 | delete gdisks[i]; |
| 732 | gdisks[i] = nullptr; |
| 733 | bad_disks++; |
| 734 | } else if (bad_disks > 0) { |
| 735 | gdisks[i - bad_disks] = gdisks[i]; |
| 736 | gdisks[i] = nullptr; |
| 737 | } |
| 738 | } |
| 739 | if (bad_disks > 0) { |
| 740 | // Update the number of available cache disks |
| 741 | gndisks -= bad_disks; |
| 742 | // Check if this is a fatal error |
| 743 | if (this->waitForCache() == 3 || (0 == gndisks && this->waitForCache() == 2)) { |
| 744 | // This could be passed off to @c cacheInitialized (as with volume config problems) but I |
| 745 | // think the more specific error message here is worth the extra code. |
| 746 | CacheProcessor::initialized = CACHE_INIT_FAILED; |
| 747 | if (cb_after_init) { |
| 748 | cb_after_init(); |
| 749 | } |
| 750 | Emergency("Cache initialization failed - only %d of %d disks were available.", gndisks, theCacheStore.n_spans_in_config); |
| 751 | } else if (this->waitForCache() == 2) { |
| 752 | Warning("Cache initialization incomplete - only %d of %d disks were available.", gndisks, theCacheStore.n_spans_in_config); |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | /* Practically just took all bad_disks offline so update the stats. */ |
| 757 | // ToDo: These don't get update on the per-volume metrics :-/ |
| 758 | ts::Metrics::Gauge::store(cache_rsb.span_offline, bad_disks); |
| 759 | ts::Metrics::Gauge::decrement(cache_rsb.span_failing, bad_disks); |
| 760 | ts::Metrics::Gauge::store(cache_rsb.span_online, gndisks); |
| 761 | |
| 762 | /* create the cachevol list only if num volumes are greater than 0. */ |
| 763 | if (config_volumes.num_volumes == 0) { |
| 764 | /* if no volumes, default to just an http cache */ |
| 765 | res = cplist_reconfigure(); |
| 766 | } else { |
| 767 | // else |
| 768 | /* create the cachevol list. */ |
| 769 | cplist_init(); |
| 770 | /* now change the cachevol list based on the config file */ |
| 771 | res = cplist_reconfigure(); |
| 772 | } |
no test coverage detected