-
Notifications
You must be signed in to change notification settings - Fork 851
Fix volume/stripe calcs when using forced volumes #6995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zwoop
merged 1 commit into
apache:master
from
gtenev:forced_volume_and_percentage_sizes_fix
Jul 14, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2530,6 +2530,8 @@ cplist_init() | |
| } | ||
| } | ||
|
|
||
| static int fillExclusiveDisks(CacheVol *cp); | ||
|
|
||
| void | ||
| cplist_update() | ||
| { | ||
|
|
@@ -2586,6 +2588,37 @@ cplist_update() | |
| cp = cp->link.next; | ||
| } | ||
| } | ||
|
|
||
| // Look for (exclusive) spans forced to a specific volume but not yet referenced by any volumes in cp_list, | ||
| // if found then create a new volume. This also makes sure new exclusive disk volumes are created first | ||
| // before any other new volumes to assure proper span free space calculation and proper volume block distribution. | ||
| for (config_vol = config_volumes.cp_queue.head; config_vol; config_vol = config_vol->link.next) { | ||
| if (nullptr == config_vol->cachep) { | ||
| // Find out if this is a forced volume assigned exclusively to a span which was cleared (hence not referenced in cp_list). | ||
| // Note: non-exclusive cleared spans are not handled here, only the "exclusive" | ||
| for (int d_no = 0; d_no < gndisks; d_no++) { | ||
| if (gdisks[d_no]->forced_volume_num == config_vol->number) { | ||
| CacheVol *new_cp = new CacheVol(); | ||
| if (nullptr != new_cp) { | ||
| new_cp->disk_vols = (DiskVol **)ats_malloc(gndisks * sizeof(DiskVol *)); | ||
| if (nullptr != new_cp->disk_vols) { | ||
| memset(new_cp->disk_vols, 0, gndisks * sizeof(DiskVol *)); | ||
| new_cp->vol_number = config_vol->number; | ||
| new_cp->scheme = config_vol->scheme; | ||
| config_vol->cachep = new_cp; | ||
| fillExclusiveDisks(config_vol->cachep); | ||
| cp_list.enqueue(new_cp); | ||
| } else { | ||
| delete new_cp; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } else { | ||
| // Fill if this is exclusive disk. | ||
| fillExclusiveDisks(config_vol->cachep); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| static int | ||
|
|
@@ -2599,20 +2632,32 @@ fillExclusiveDisks(CacheVol *cp) | |
| if (gdisks[i]->forced_volume_num != volume_number) { | ||
| continue; | ||
| } | ||
| /* The user had created several volumes before - clear the disk | ||
| and create one volume for http */ | ||
| for (int j = 0; j < static_cast<int>(gdisks[i]->header->num_volumes); j++) { | ||
|
|
||
| /* OK, this should be an "exclusive" disk (span). */ | ||
| diskCount++; | ||
|
|
||
| /* There should be a single "forced" volume and no other volumes should exist on this "exclusive" disk (span) */ | ||
| bool found_nonforced_volumes = false; | ||
| for (int j = 0; j < (int)gdisks[i]->header->num_volumes; j++) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if (volume_number != gdisks[i]->disk_vols[j]->vol_number) { | ||
| Note("Clearing Disk: %s", gdisks[i]->path); | ||
| gdisks[i]->delete_all_volumes(); | ||
| found_nonforced_volumes = true; | ||
| break; | ||
| } | ||
| } | ||
| diskCount++; | ||
|
|
||
| if (found_nonforced_volumes) { | ||
| /* The user had created several volumes before - clear the disk and create one volume for http */ | ||
| Note("Clearing Disk: %s", gdisks[i]->path); | ||
| gdisks[i]->delete_all_volumes(); | ||
| } else if (1 == gdisks[i]->header->num_volumes) { | ||
| /* "Forced" volumes take the whole disk (span) hence nothing more to do for this span. */ | ||
| continue; | ||
| } | ||
|
|
||
| /* Now, volumes have been either deleted or did not existing to begin with so we need to create them. */ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "or did not exist to begin with" |
||
|
|
||
| int64_t size_diff = gdisks[i]->num_usable_blocks; | ||
| DiskVolBlock *dpb; | ||
|
|
||
| do { | ||
| dpb = gdisks[i]->create_volume(volume_number, size_diff, cp->scheme); | ||
| if (dpb) { | ||
|
|
@@ -2628,6 +2673,8 @@ fillExclusiveDisks(CacheVol *cp) | |
| } | ||
| } while ((size_diff > 0)); | ||
| } | ||
|
|
||
| /* Report back the number of disks (spans) that were assigned to volume specified by volume_number. */ | ||
| return diskCount; | ||
| } | ||
|
|
||
|
|
@@ -2692,7 +2739,11 @@ cplist_reconfigure() | |
| /* sum up the total space available on all the disks. | ||
| round down the space to 128 megabytes */ | ||
| for (int i = 0; i < gndisks; i++) { | ||
| tot_space_in_blks += (gdisks[i]->num_usable_blocks / blocks_per_vol) * blocks_per_vol; | ||
| // Exclude exclusive disks (with forced volumes) from the following total space calculation, | ||
| // in such a way forced volumes will not impact volume percentage calculations. | ||
| if (-1 == gdisks[i]->forced_volume_num) { | ||
| tot_space_in_blks += (gdisks[i]->num_usable_blocks / blocks_per_vol) * blocks_per_vol; | ||
| } | ||
| } | ||
|
|
||
| double percent_remaining = 100.00; | ||
|
|
@@ -2721,16 +2772,8 @@ cplist_reconfigure() | |
| config_vol->ramcache_enabled); | ||
| } | ||
| cplist_update(); | ||
| /* go through volume config and grow and create volumes */ | ||
|
|
||
| for (config_vol = config_volumes.cp_queue.head; config_vol; config_vol = config_vol->link.next) { | ||
| // if volume is given exclusive disks, fill here and continue | ||
| if (!config_vol->cachep) { | ||
| continue; | ||
| } | ||
| fillExclusiveDisks(config_vol->cachep); | ||
| } | ||
|
|
||
| /* go through volume config and grow and create volumes */ | ||
| for (config_vol = config_volumes.cp_queue.head; config_vol; config_vol = config_vol->link.next) { | ||
| size = config_vol->size; | ||
| if (size < 128) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No C-style casts. Because it's a
void *,static_castshould work. You could tryto be extra fancy :-P