Skip to content
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

do not allow allow users to shrink zvol with GUI. #957

Closed
wants to merge 4 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -293,8 +293,9 @@ export class ZvolFormComponent {
let compression_collection = [{label:pk_dataset[0].compression.value, value: pk_dataset[0].compression.value}];
let deduplication_collection = [{label:pk_dataset[0].deduplication.value, value: pk_dataset[0].deduplication.value}];

const volumesize = pk_dataset[0].volsize.value.match(/[a-zA-Z]+|[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)+/g)[0];
let volumesize = pk_dataset[0].volsize.parsed;
const volumeunit = pk_dataset[0].volsize.value.match(/[a-zA-Z]+|[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)+/g)[1];
volumesize = volumesize/this.byteMap[volumeunit];


entityForm.formGroup.controls['name'].setValue(pk_dataset[0].name);
Expand Down Expand Up @@ -379,7 +380,6 @@ export class ZvolFormComponent {
if (data.deduplication === 'INHERIT') {
delete(data.deduplication);
}
data.volsize = Math.round(data.volsize);
if (data.volblocksize !== 'INHERIT') {
let volblocksize_integer_value = data.volblocksize.match(/[a-zA-Z]+|[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)+/g)[0];
volblocksize_integer_value = parseInt(volblocksize_integer_value,10)
Expand All @@ -394,7 +394,7 @@ export class ZvolFormComponent {

data.volsize = data.volsize + (volblocksize_integer_value - data.volsize%volblocksize_integer_value)


} else{
delete(data.volblocksize);
}
Expand All @@ -412,15 +412,28 @@ export class ZvolFormComponent {
} else {
volblocksize_integer_value = volblocksize_integer_value * 1024
}
this.edit_data.volsize = this.edit_data.volsize + (volblocksize_integer_value - this.edit_data.volsize%volblocksize_integer_value)
this.ws.call('pool.dataset.update', [this.parent, this.edit_data]).subscribe((restPostResp) => {
this.loader.close();
this.router.navigate(new Array('/').concat(
this.route_success));
}, (eres) => {
if(this.edit_data.volsize%volblocksize_integer_value !== 0){
this.edit_data.volsize = this.edit_data.volsize + (volblocksize_integer_value - this.edit_data.volsize%volblocksize_integer_value)
}
let rounded_vol_size = res[0].volsize.parsed

if(res[0].volsize.parsed%volblocksize_integer_value !== 0){
rounded_vol_size = res[0].volsize.parsed + (volblocksize_integer_value - res[0].volsize.parsed%volblocksize_integer_value)
}

if(this.edit_data.volsize >= rounded_vol_size){
this.ws.call('pool.dataset.update', [this.parent, this.edit_data]).subscribe((restPostResp) => {
this.loader.close();
this.router.navigate(new Array('/').concat(
this.route_success));
}, (eres) => {
this.loader.close();
this.dialogService.errorReport(T("Error saving ZVOL"), eres.reason, eres.trace.formatted);
});
} else{
this.loader.close();
this.dialogService.errorReport(T("Error saving ZVOL"), eres.reason, eres.trace.formatted);
});
this.dialogService.Info(T("Error saving ZVOL"), "You cannot shrink a ZVOL from gui this may lead to data loss.")
}
})
}

Expand Down