[stgt] [PATCH 2/5] tgtadm: expose blocksize option
Andy Grover
agrover at redhat.com
Thu Oct 27 03:21:00 CEST 2011
From: Federico Simoncelli <fsimonce at redhat.com>
This patch adds the new option --blocksize (or -y) to expose a custom block
size for the LUN.
Signed-off-by: Federico Simoncelli <fsimonce at redhat.com>
Signed-off-by: Andy Grover <agrover at redhat.com>
---
scripts/tgt-admin | 8 +++++++-
usr/tgtadm.c | 16 ++++++++++++----
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/scripts/tgt-admin b/scripts/tgt-admin
index 9f34022..870f3bd 100755
--- a/scripts/tgt-admin
+++ b/scripts/tgt-admin
@@ -464,6 +464,7 @@ sub add_backing_direct {
my @exec_commands;
my $device_type;
my $bs_type;
+ my $block_size;
my %luns;
my @added_luns;
# Find out LUNs which are "reserved" in the config file
@@ -514,6 +515,10 @@ sub add_backing_direct {
$bs_type = $result;
$params_added{$store_option} = 1;
}
+ if ($store_option eq "block-size") {
+ $block_size = $result;
+ $params_added{$store_option} = 1;
+ }
if ($store_option eq "mode_page") {
unless (ref($result) eq 'ARRAY') {
$result = [ $result ];
@@ -635,7 +640,8 @@ sub add_backing_direct {
# Execute commands for a given LUN
if (length $device_type) { $device_type = "--device-type $device_type" };
if (length $bs_type) { $bs_type = "--bstype $bs_type" };
- execute("tgtadm -C $control_port --lld $driver --op new --mode logicalunit --tid $next_tid --lun $lun -b $backing_store $device_type $bs_type");
+ if (length $block_size) { $block_size = "--blocksize $block_size" };
+ execute("tgtadm -C $control_port --lld $driver --op new --mode logicalunit --tid $next_tid --lun $lun -b $backing_store $device_type $bs_type $block_size");
# Commands should be executed in order
my @execute_last;
diff --git a/usr/tgtadm.c b/usr/tgtadm.c
index b2b1aa3..398398b 100644
--- a/usr/tgtadm.c
+++ b/usr/tgtadm.c
@@ -104,6 +104,7 @@ struct option const long_options[] = {
{"backing-store", required_argument, NULL, 'b'},
{"bstype", required_argument, NULL, 'E'},
{"bsoflags", required_argument, NULL, 'f'},
+ {"blocksize", required_argument, NULL, 'y'},
{"targetname", required_argument, NULL, 'T'},
{"initiator-address", required_argument, NULL, 'I'},
{"initiator-name", required_argument, NULL, 'Q'},
@@ -119,7 +120,7 @@ struct option const long_options[] = {
{NULL, 0, NULL, 0},
};
-static char *short_options = "dhVL:o:m:t:s:c:l:n:v:b:E:f:T:I:Q:u:p:H:F:P:B:Y:O:C:";
+static char *short_options = "dhVL:o:m:t:s:c:l:n:v:b:E:f:y:T:I:Q:u:p:H:F:P:B:Y:O:C:";
static void usage(int status)
{
@@ -441,6 +442,7 @@ int main(int argc, char **argv)
char *name, *value, *path, *targetname, *params, *address, *iqnname, *targetOps;
char *portalOps, *bstype;
char *bsoflags;
+ char *blocksize;
char *user, *password;
char *buf;
size_t bufsz = BUFSIZE + sizeof(struct tgtadm_req);
@@ -456,7 +458,7 @@ int main(int argc, char **argv)
rest = BUFSIZE;
name = value = path = targetname = address = iqnname = NULL;
targetOps = portalOps = bstype = NULL;
- bsoflags = user = password = NULL;
+ bsoflags = blocksize = user = password = NULL;
force = 0;
buf = valloc(bufsz);
@@ -540,6 +542,9 @@ int main(int argc, char **argv)
case 'f':
bsoflags = optarg;
break;
+ case 'y':
+ blocksize = optarg;
+ break;
case 'E':
bstype = optarg;
break;
@@ -751,7 +756,7 @@ int main(int argc, char **argv)
}
switch (op) {
case OP_NEW:
- rc = verify_mode_params(argc, argv, "LmoftlbEYC");
+ rc = verify_mode_params(argc, argv, "LmofytlbEYC");
if (rc) {
eprintf("target mode: option '-%c' is not "
"allowed/supported\n", rc);
@@ -772,7 +777,7 @@ int main(int argc, char **argv)
}
break;
case OP_UPDATE:
- rc = verify_mode_params(argc, argv, "LmoftlPC");
+ rc = verify_mode_params(argc, argv, "LmofytlPC");
if (rc) {
eprintf("option '-%c' not supported in "
"logicalunit mode\n", rc);
@@ -859,6 +864,9 @@ int main(int argc, char **argv)
if (bsoflags)
shprintf(total, params, rest, "%sbsoflags=%s",
rest == BUFSIZE ? "" : ",", bsoflags);
+ if (blocksize)
+ shprintf(total, params, rest, "%sblocksize=%s",
+ rest == BUFSIZE ? "" : ",", blocksize);
if (targetname)
shprintf(total, params, rest, "%stargetname=%s",
rest == BUFSIZE ? "" : ",", targetname);
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list