Skip to content

Commit

Permalink
feat(tunings): luworkers and queudepth settings through env (#234)
Browse files Browse the repository at this point in the history
Signed-off-by: Vitta <[email protected]>
  • Loading branch information
vishnuitta authored and pawanpraka1 committed Mar 4, 2019
1 parent 39771ce commit e5103d9
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 43 deletions.
10 changes: 9 additions & 1 deletion src/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ do
externalIP) externalIP=${VALUE} ;;
replication_factor) replication_factor=${VALUE} ;;
consistency_factor) consistency_factor=${VALUE} ;;
test_env) test_env=${VALUE} ;;
*)
esac
done
Expand Down Expand Up @@ -65,7 +66,14 @@ export externalIP=$externalIP
echo $externalIP
service rsyslog start
#setting replica timeout to 20 seconds
/usr/local/bin/istgt -R 20

if [ -z $test_env ]
then
/usr/local/bin/istgt -R 20
else
QueueDepth=5 Luworkers=9 /usr/local/bin/istgt -R 20
fi

child=$!
echo "child PID from init script: "$child
wait
103 changes: 63 additions & 40 deletions src/istgt_lu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,67 @@ istgt_lu_set_local_settings(ISTGT_Ptr istgt, CF_SECTION *sp, ISTGT_LU_Ptr lu)

extern int g_num_luworkers;

static void set_queue_depth(CF_SECTION *sp, ISTGT_LU_Ptr lu)
{
const char* val = getenv("QueueDepth");
if (val)
ISTGT_TRACELOG(ISTGT_TRACE_DEBUG, "setting queuedepth from env to %s\n", val);
else
val = istgt_get_val(sp, "QueueDepth");

if (val == NULL) {
switch (lu->type) {
case ISTGT_LU_TYPE_DISK:
lu->queue_depth = DEFAULT_LU_QUEUE_DEPTH;
// lu->queue_depth = 0;
break;
case ISTGT_LU_TYPE_DVD:
case ISTGT_LU_TYPE_TAPE:
default:
lu->queue_depth = 0;
break;
}
} else {
lu->queue_depth = (int) strtol(val, NULL, 10);
}
if (lu->queue_depth < 0 || lu->queue_depth >= MAX_LU_QUEUE_DEPTH) {
ISTGT_ERRLOG("LU%d: queue depth %d is not in range, resetting to %d\n", lu->num, lu->queue_depth, DEFAULT_LU_QUEUE_DEPTH);
lu->queue_depth = DEFAULT_LU_QUEUE_DEPTH;
}
}

static void set_luworkers(CF_SECTION *sp, ISTGT_LU_Ptr lu)
{
const char* val = getenv("Luworkers");
if (val)
ISTGT_TRACELOG(ISTGT_TRACE_DEBUG, "setting luworkers from env to %s\n", val);
else
val = istgt_get_val(sp, "Luworkers");

if (val == NULL) {
switch (lu->type) {
case ISTGT_LU_TYPE_DISK:
lu->luworkers = g_num_luworkers;
break;
case ISTGT_LU_TYPE_DVD:
case ISTGT_LU_TYPE_TAPE:
default:
lu->luworkers = 0;
break;
}
} else {
lu->luworkers = (int) strtol(val, NULL, 10);
if (lu->luworkers > (ISTGT_MAX_NUM_LUWORKERS - 1)) {
ISTGT_ERRLOG("LU%d: luworkers %d is not in range, resetting to %d\n", lu->num, lu->luworkers, ISTGT_MAX_NUM_LUWORKERS - 1);
lu->luworkers = (ISTGT_MAX_NUM_LUWORKERS - 1);
}
else if (lu->luworkers < 1) {
ISTGT_ERRLOG("LU%d: luworkers %d is not in range, resetting to %d\n", lu->num, lu->luworkers, 1);
lu->luworkers = 1;
}
}
}

static int
istgt_lu_add_unit(ISTGT_Ptr istgt, CF_SECTION *sp)
{
Expand Down Expand Up @@ -1799,27 +1860,7 @@ istgt_lu_add_unit(ISTGT_Ptr istgt, CF_SECTION *sp)
}
}

val = istgt_get_val(sp, "QueueDepth");
if (val == NULL) {
switch (lu->type) {
case ISTGT_LU_TYPE_DISK:
lu->queue_depth = DEFAULT_LU_QUEUE_DEPTH;
// lu->queue_depth = 0;
break;
case ISTGT_LU_TYPE_DVD:
case ISTGT_LU_TYPE_TAPE:
default:
lu->queue_depth = 0;
break;
}
} else {
lu->queue_depth = (int) strtol(val, NULL, 10);
}
if (lu->queue_depth < 0 || lu->queue_depth >= MAX_LU_QUEUE_DEPTH) {
ISTGT_ERRLOG("LU%d: queue depth %d is not in range, resetting to %d\n", lu->num, lu->queue_depth, DEFAULT_LU_QUEUE_DEPTH);
lu->queue_depth = DEFAULT_LU_QUEUE_DEPTH;
goto error_return;
}
set_queue_depth(sp, lu);

lu->luworkers = 0;
lu->luworkersActive = 0;
Expand All @@ -1829,25 +1870,7 @@ istgt_lu_add_unit(ISTGT_Ptr istgt, CF_SECTION *sp)
ISTGT_TRACELOG(ISTGT_TRACE_DEBUG, "BlockLength %d, PhysRecordLength %d, QueueDepth %d\n",
lu->blocklen, lu->recordsize, lu->queue_depth);

val = istgt_get_val(sp, "Luworkers");
if (val == NULL) {
switch (lu->type) {
case ISTGT_LU_TYPE_DISK:
lu->luworkers = g_num_luworkers;
break;
case ISTGT_LU_TYPE_DVD:
case ISTGT_LU_TYPE_TAPE:
default:
lu->luworkers = 0;
break;
}
} else {
lu->luworkers = (int) strtol(val, NULL, 10);
if (lu->luworkers > (ISTGT_MAX_NUM_LUWORKERS - 1))
lu->luworkers = (ISTGT_MAX_NUM_LUWORKERS - 1);
else if (lu->luworkers < 1)
lu->luworkers = 1;
}
set_luworkers(sp, lu);

lu->maxlun = 0;
for (i = 0; i < MAX_LU_LUN; i++) {
Expand Down
4 changes: 2 additions & 2 deletions src/setup_istgt.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

set -x
run_istgt ()
{
local volume_size
Expand All @@ -24,7 +24,7 @@ run_istgt ()
cp istgt /usr/local/bin/istgt
cp istgtcontrol /usr/local/bin/istgtcontrol
ps -aux | grep "\./istgt" | grep -v grep | sudo kill -9 `awk '{print $2}'`
./init.sh volname=vol1 portal=127.0.0.1 size=$volume_size externalIP=127.0.0.1 replication_factor=$rf consistency_factor=$cf
./init.sh volname=vol1 portal=127.0.0.1 size=$volume_size externalIP=127.0.0.1 replication_factor=$rf consistency_factor=$cf test_env=$TEST_ENV
}

parent_file=$( basename $0 )
Expand Down
31 changes: 31 additions & 0 deletions test_istgt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ start_replica() {
stop_istgt() {
if [ $SETUP_PID -ne -1 ]; then
pkill -9 -P $(list_descendants $SETUP_PID)
kill -9 $(list_descendants $SETUP_PID)
pkill -9 -P $SETUP_PID
kill -9 $SETUP_PID
fi

}
Expand Down Expand Up @@ -1262,6 +1264,34 @@ run_replication_factor_test()
fi
}

run_test_env()
{
REPLICATION_FACTOR=3
CONSISTENCY_FACTOR=2
TEST_ENV=1
setup_test_env

cnt=$(eval $ISTGTCONTROL dump -a | grep "Luworkers:9" | wc -l)
if [ $? -ne 0 ] || [ $cnt -ne 1 ]
then
echo "test env failed"
exit 1
fi
cleanup_test_env

unset TEST_ENV
setup_test_env

cnt=$(eval $ISTGTCONTROL dump -a | grep "Luworkers:6" | wc -l)
if [ $? -ne 0 ] || [ $cnt -ne 1 ]
then
echo "test env failed"
exit 1
fi
cleanup_test_env
}


run_io_timeout_test()
{
local replica1_port="6161"
Expand Down Expand Up @@ -1370,6 +1400,7 @@ run_istgt_integration
run_read_consistency_test
run_replication_factor_test
run_io_timeout_test
run_test_env
echo "===============All Tests are passed ==============="
tail -20 $LOGFILE

Expand Down

0 comments on commit e5103d9

Please sign in to comment.