Skip to content

Commit

Permalink
fix max size computation with thin pools (bnc#803981)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Fehr committed Feb 18, 2013
1 parent d91a0a6 commit e014376
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
27 changes: 25 additions & 2 deletions storage/src/include/ep-lvm-dialogs.ycp
Expand Up @@ -201,6 +201,24 @@ in volume group \"%2\"."),
}


integer ComputePoolMetadataSize( integer siz, integer pesize )
{
integer chunk = 64;
integer metasize = siz/chunk/(1024/64);
if( metasize<2*1024 )
metasize = 2*1024;
while( chunk<=1048576 && metasize>128*1024 )
{
chunk = chunk*2;
metasize = metasize/2;
}
integer pe_k = pesize/1024;
metasize = (metasize+pe_k-1)/pe_k*pe_k;
y2milestone( "ComputePoolMetadataSize size:%1 pe:%2 chunk:%3 ret:%4",
siz, pe_k, chunk, metasize );
return( metasize );
}

string MiniWorkflowStepVgHelptext()
{
// helptext
Expand Down Expand Up @@ -411,17 +429,22 @@ Thin Volumes cannot have a Stripe Count.");

integer min_size_k = data["pesize"]:0 / 1024;
integer max_size_k = data["max_size_k"]:0;
boolean thin = !isempty(data["used_pool"]:"");
boolean pool = data["pool"]:false;
if( pool )
max_size_k = max_size_k -
ComputePoolMetadataSize(data["max_size_k"]:0,
data["pesize"]:0);
integer size_k = data["size_k"]:max_size_k;

symbol what = (size_k == max_size_k) ? `max_size : `manual_size;
string name = data["name"]:"";
string max_s = sformat(_("Maximum Size (%1)"), Storage::KByteToHumanString(max_size_k));
boolean thin = !isempty(data["used_pool"]:"");
if( thin )
{
what = `manual_size;
max_size_k = 1024*1024*1024*1024*1024;
size_k = 900*1024;
size_k = 2*1024*1024;
integer pos = search( max_s, "(" );
if( pos!=nil )
max_s = substring( max_s, 0, pos );
Expand Down
9 changes: 8 additions & 1 deletion storage/src/include/ep-lvm-lib.ycp
Expand Up @@ -226,7 +226,14 @@ RAID device is required. Change your partition table accordingly."));

data["vg_name"] = vg_name;
data["pesize"] = target_map[device, "pesize"]:0;
data["max_size_k"] = (target_map[device, "pe_free"]:0 * target_map[device, "pesize"]:0) / 1024;
integer maxs = target_map[device, "pe_free"]:0 * target_map[device, "pesize"]:0 / 1024;
foreach( map p, target_map[device,"partitions"]:[],
{
if( p["create"]:false && p["pool"]:false )
maxs = maxs - ComputePoolMetadataSize( p["size_k"]:0,
target_map[device,"pesize"]:1024 );
});
data["max_size_k"] = maxs;
data["max_stripes"] = size(MergeDevices((map<string, any>) target_map[device]:$[]));

data["using_devices"] = [ device ];
Expand Down

0 comments on commit e014376

Please sign in to comment.