[PATCH 1/3] tgtadm: expose blocksize option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Federico Simoncelli <fsimonce@xxxxxxxxxx>

This patch adds the new option --blocksize (or -y) to expose a custom block
size for the LUN.

Signed-off-by: Federico Simoncelli <fsimonce@xxxxxxxxxx>
Signed-off-by: Andy Grover <agrover@xxxxxxxxxx>
---
 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 176f2e8..aa16b79 100755
--- a/scripts/tgt-admin
+++ b/scripts/tgt-admin
@@ -463,6 +463,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
@@ -513,6 +514,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 ];
@@ -634,7 +639,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 5e107a4..0b5e4b8 100644
--- a/usr/tgtadm.c
+++ b/usr/tgtadm.c
@@ -103,6 +103,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'},
@@ -118,7 +119,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)
 {
@@ -440,6 +441,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);
@@ -455,7 +457,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);
@@ -539,6 +541,9 @@ int main(int argc, char **argv)
 		case 'f':
 			bsoflags = optarg;
 			break;
+		case 'y':
+			blocksize = optarg;
+			break;
 		case 'E':
 			bstype = optarg;
 			break;
@@ -750,7 +755,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);
@@ -771,7 +776,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);
@@ -858,6 +863,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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux