Commit da4f7c66 authored by Brian Meagher's avatar Brian Meagher Committed by Gleb Chesnokov
Browse files

scst_vdisk, scstadmin: Allow t10_dev_id to be stored before cluster_mode

Since cluster_mode relies upon the t10_dev_id to generate a namespace, once
cluster_mode is set the t10_dev_id can no longer be changed.

However, because cluster_mode is listed as one of the various add_dev_params,
this meant that it would be set earlier than t10_dev_id when scstadmin
processes scst.conf

Rectify by adding t10_dev_id to fileio_add_dev_params, etc and modifying the
SCST.pm openDevice so that cluster_mode is set last.
Showing with 38 additions and 1 deletion
+38 -1
......@@ -6993,6 +6993,33 @@ static int vdev_parse_add_dev_params(struct scst_vdisk_dev *virt_dev,
continue;
}
if (!strcasecmp("t10_dev_id", p)) {
/* Handle in a fashion similar to vdev_sysfs_t10_dev_id_store */
int i, length = strlen(pp);
if (length >= sizeof(virt_dev->t10_dev_id)) {
PRINT_ERROR("T10 device id is too long (max %zd "
"characters)", sizeof(virt_dev->t10_dev_id)-1);
res = -EINVAL;
goto out;
}
memset(virt_dev->t10_dev_id, 0, sizeof(virt_dev->t10_dev_id));
memcpy(virt_dev->t10_dev_id, pp, length);
i = 0;
while (i < sizeof(virt_dev->t10_dev_id)) {
if (virt_dev->t10_dev_id[i] == '\n') {
virt_dev->t10_dev_id[i] = '\0';
break;
}
i++;
}
virt_dev->t10_dev_id_set = 1;
continue;
}
res = kstrtoll(pp, 0, &ll_val);
if (res != 0) {
PRINT_ERROR("strtoll() for %s failed: %d (device %s)",
......@@ -9604,6 +9631,7 @@ static const char *const fileio_add_dev_params[] = {
"rotational",
"thin_provisioned",
"tst",
"t10_dev_id",
"write_through",
NULL
};
......@@ -9695,6 +9723,7 @@ static const char *const blockio_add_dev_params[] = {
"rotational",
"thin_provisioned",
"tst",
"t10_dev_id",
"write_through",
NULL
};
......@@ -9768,6 +9797,7 @@ static const char *const nullio_add_dev_params[] = {
"size",
"size_mb",
"tst",
"t10_dev_id",
NULL
};
......
......@@ -3911,10 +3911,17 @@ sub openDevice {
if (!valid($handler, $device, $attributes));
my $o_string = "";
## Special case cluster_mode as we want to set it after t10_dev_id
my $cm_string = "";
foreach my $attribute (keys %{$attributes}) {
my $value = $$attributes{$attribute};
$o_string .= "$attribute=$value;";
if ($attribute eq "cluster_mode") {
$cm_string = "$attribute=$value;";
} else {
$o_string .= "$attribute=$value;";
}
}
$o_string .= $cm_string;
$o_string =~ s/\s$//;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment