From fd43003403a8447d9f387773e7d6d3f3eb752b43 Mon Sep 17 00:00:00 2001 From: Jay Martinez Date: Thu, 18 Aug 2011 16:09:49 -0700 Subject: [PATCH 01/10] OSD-TARGET: Changes to receive an osd name from tgtadm through tgtd and record the osd name. This is patch 2/2. The first patch modifies tgtadm and tgtd to get the osd name as parameter from command line. usage has explained at the first patch [1/2]. Signed-off-by: Jay Martinez --- osd-target/cdb.h | 1 + osd-target/osd.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/osd-target/cdb.h b/osd-target/cdb.h index e60b88a..98b98bb 100644 --- a/osd-target/cdb.h +++ b/osd-target/cdb.h @@ -29,5 +29,6 @@ int osdemu_cmd_submit(struct osd_device *osd, uint8_t *cdb, const uint8_t *data_in, uint64_t data_in_len, uint8_t **data_out, uint64_t *data_out_len, uint8_t *sense_out, int *senselen_out); +int osd_set_name(struct osd_device *osd, char *osdname); #endif /* __CDB_H */ diff --git a/osd-target/osd.c b/osd-target/osd.c index a7d9cb1..bb7d0e6 100644 --- a/osd-target/osd.c +++ b/osd-target/osd.c @@ -1084,6 +1084,22 @@ int osd_open(const char *root, struct osd_device *osd) return ret; } +int osd_set_name(struct osd_device *osd, char *osdname) +{ + int ret = 0; + + osd_info("Setting osdname => %s",osdname); + + ret = attr_set_attr(osd->dbc, 0, 0, ROOT_INFO_PG,RIAP_OSD_NAME, + osdname, strlen(osdname)); + + if ( OSD_OK != ret){ + osd_error("!attr_set_attr => %d", ret); + } + + return ret; +} + int osd_close(struct osd_device *osd) { int ret; From b8be9d406a5b066106de6f013e3c1d4c6b505cd6 Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Tue, 1 Nov 2011 16:41:58 -0700 Subject: [PATCH 02/10] NOTFINAL: tgt: Add support for specifying osdname on commandline This syncs with Jay's : [3a36ffa] OSD-TARGET: Adding osd name parameter to tgtadm I will want to change that and work is under way, but for SC11 testing we'll use it like that Boaz --- .gitignore | 3 ++- tgt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 66c01ae..6bfdae3 100644 --- a/.gitignore +++ b/.gitignore @@ -36,7 +36,7 @@ old-tars patches # -# programs & Tests +# programs, Tests & logs # osd-initiator/tests/alignment osd-initiator/tests/atomic @@ -62,6 +62,7 @@ osd-target/tests/list osd-target/tests/query osd-target/tests/set_member_attributes osd-target/tests/setattr +otgtd.log # files made by make osd-target/osd-schema.c diff --git a/tgt b/tgt index 91122c2..3a36ffa 160000 --- a/tgt +++ b/tgt @@ -1 +1 @@ -Subproject commit 91122c287dd35cd5f85f3f75da4226b87736ef35 +Subproject commit 3a36ffaaa41e8eccdc1fcac8fe8ded80771fce61 From 9652186d2ce7715437a643fbf78cc7ba3d08f259 Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Mon, 6 Jun 2011 22:39:28 +0300 Subject: [PATCH 03/10] open-osd: up: Complete revamp of ./up script This is partly based on the scripts we used for the JUNE11 testing. * Split all configuration into an up.conf file If up.conf does not exist in current dir, an example one is created and user is instructed to edit it. * Load as many targets as defined in up.conf file. * Script no longer stays in foreground, it will redirect all output into a log file (defined in up.conf) and exit after loading. * Add more sub-commands to the up script: - up "" : No sub-command try to load a target as before - up down: Properly shut down a running otgtd daemon - up stat: Print "UP" or "DOWN" depending of otgtd presence in "ps ax" - up show: Use tgtadm to print currently loaded targets - up log: "less" into the log-file at end (+F) - up log-reset empty current log file * teach .gitignore to ignore up.conf Hopefully this stops the ./up bickering back and forth every new setup. Signed-off-by: Boaz Harrosh --- .gitignore | 1 + osd-target/osd.c | 1 + up | 115 +++++++++++++++++++++++++++++++++++------------ 3 files changed, 88 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 6bfdae3..9bfd4aa 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,7 @@ osd-target/tests/query osd-target/tests/set_member_attributes osd-target/tests/setattr otgtd.log +up.conf # files made by make osd-target/osd-schema.c diff --git a/osd-target/osd.c b/osd-target/osd.c index bb7d0e6..4b2238b 100644 --- a/osd-target/osd.c +++ b/osd-target/osd.c @@ -2529,6 +2529,7 @@ int osd_list(struct osd_device *osd, uint8_t list_attr, uint64_t pid, add_len = (uint64_t) -1; set_htonll(outdata, add_len); set_htonll(&outdata[8], cont_id); +osd_error("%s: add_len=%lu cont_id=0x%lx", __func__, add_len, cont_id); } else if (list_attr == 1 && get_attr->sz != 0 && pid != 0) { if (list_id) initial_oid = cont_id; diff --git a/up b/up index 257a5c7..ffe78ee 100755 --- a/up +++ b/up @@ -1,24 +1,84 @@ #!/bin/sh -# Path to executables, assuming source tree +up_dir=`dirname $0` +up_conf=./up.conf + +if [ -r $up_conf ]; then + source $up_conf; +else + echo -n " +# up.conf Configuration of the targets to load + +# The number of targets to load +NUM_TARGETS=1 +LOG_FILE=./otgtd.log + +# Please edit the path to your osd-target backing store. +# You can add as many BACKSTORE[1..n] as you need. Each one +# will have a new target loaded for it. +BACKSTORE[1]=/var/otgt/otgt-1 +# BACKSTORE[2]=/var/otgt/otgt-2 +# BACKSTORE[3]=/var/otgt/otgt-3 +" > $up_conf; + + echo "$up_conf not found I have created a new one for you please + edit and re-run ./up + " + exit +fi + +# Path to pan_tgtd executables, assuming source tree TGTADM=./tgt/usr/tgtadm -OTGTD=./tgt/usr/otgtd - -# must have target 1 -BACKSTORE1=/usr0/var/osd-tgt/tgt-1/ -# Optional additional back-stores here -BACKSTORE2=/usr0/var/osd-tgt/tgt-2/ -BACKSTORE3=/usr0/var/osd-tgt/tgt-3/ -BACKSTORE4=/usr0/var/osd-tgt/tgt-4/ -BACKSTORE5=/usr0/var/osd-tgt/tgt-5/ -BACKSTORE6=/usr0/var/osd-tgt/tgt-6/ -BACKSTORE7=/usr0/var/osd-tgt/tgt-7/ -BACKSTORE8=/usr0/var/osd-tgt/tgt-8/ - -# $1<=BACKSTORE $2<=tid +otgtd_name=otgtd +OTGTD=./tgt/usr/$otgtd_name + +# Make target name the hostname +TARGETNAME="${1//\//\.}$(hostname)" + +case $1 in +down) + killall -s SIGINT $otgtd_name + exit + ;; +stat) + _ps=`ps ax` + stat=`echo $_ps | grep $otgtd_name` + if [ "${stat}" == "" ] ; then + echo "otgtd: DOWN!!!" + else + echo "otgtd: UP" + fi + exit + ;; +show) + $TGTADM --lld iscsi --mode target --op show + exit + ;; + +log) + less +F $LOG_FILE + exit + ;; + +log-reset) + echo > $LOG_FILE + exit + ;; + +*) + if [ -n "$1" ]; then + echo "what is $0 $1?!?" + exit + fi + ;; +esac + +# Usage: $1<=BACKSTORE $2<=tid load_target() { -$TGTADM --lld iscsi --mode target --op new --tid $2 --targetname ${1//\//\.}$(hostname) +mkdir -p $1/ + +$TGTADM --lld iscsi --mode target --op new --tid $2 --targetname="$TARGETNAME"-"$1" $TGTADM --lld iscsi --mode target \ --op bind --tid $2 --initiator-address ALL @@ -27,27 +87,24 @@ $TGTADM --lld iscsi --mode logicalunit \ --backing-store $1 } +echo "================ `date` =========================" >> $LOG_FILE + # First run the otgtd daemon in forgraound # -f - forgraound # -d - debug level # DEBUG="-d 9" DEBUG="" -$OTGTD $DEBUG -f & +$OTGTD $DEBUG -f &>> $LOG_FILE & sleep 2 # 2nd Load some targets +for ((t=1; t <= $NUM_TARGETS; t=$t+1)); do + echo load_target ${BACKSTORE[$t]} $t + load_target ${BACKSTORE[$t]} $t +done -load_target $BACKSTORE1 1 -load_target $BACKSTORE2 2 -load_target $BACKSTORE3 3 -load_target $BACKSTORE4 4 - -load_target $BACKSTORE5 5 -load_target $BACKSTORE6 6 -load_target $BACKSTORE7 7 -load_target $BACKSTORE8 8 - -# Last print what we got, then stay in forgraound (ctrl-C to exit) +# Last print what we got $TGTADM --lld iscsi --mode target --op show -wait + +echo "otgtd started, run \"up down\" to stop" From f2378b46adce11d6b283bff76c657a8fe8110888 Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Sat, 15 Oct 2011 12:33:50 +0200 Subject: [PATCH 04/10] open-osd: up-pan: Add StorageBlade csh version of ./up This is a csh version of ./up scrip as needed on Panasas StorageBlade. Signed-off-by: Boaz Harrosh --- up-pan | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 up-pan diff --git a/up-pan b/up-pan new file mode 100755 index 0000000..90d1ef3 --- /dev/null +++ b/up-pan @@ -0,0 +1,66 @@ +#!/bin/csh -x + +# On Pan-OSD there is only one target +set BACKSTORE0=/root/pandata/ +# Path to pan_tgtd executables, assuming p4 integration +dir="/pan/bin" +set TGTADM=$dir/tgtadm +set OTGTD=$dir/pan_tgtd + +# Get the osd device id +set TARGETNAME=`/pan/bin/getdevinfo -q datasn` +# logfile name +set LOG="/var/log/otgtd.log" + +switch($1) +case "down": + killall $OTGTD + exit + breaksw + +case "log": + less +F $LOG + exit + breaksw +case "log-reset": + echo > $LOG + exit + breaksw + +default: + if ("$1" != "") then + echo "what is $0 $1?!?" + exit + endif + breaksw +endsw + +# On Panasas-osd we must make sure that: +mkdir -p $BACKSTORE0/ +ln -sf /pandata $BACKSTORE0/dfiles + +echo "================ `date` =========================" >> $LOG + +# First run the otgtd daemon in forgraound +# -f - forgraound +# -d - debug level +# DEBUG="-d 9" +#set DEBUG "" +$OTGTD --iscsi portal=:3251 -f >>& $LOG & + +sleep 2 + +# 2nd Load the target +#load_target $BACKSTORE0 1 +$TGTADM --lld iscsi --mode target --op new --tid 1 --targetname=$TARGETNAME +$TGTADM --lld iscsi --mode target \ + --op bind --tid 1 --initiator-address ALL + +$TGTADM --lld iscsi --mode logicalunit \ + --op new --tid 1 --lun 0 --bstype=osdemu --device-type osd \ + --backing-store $BACKSTORE0 --osd_name 06$TARGETNAME + +# Last print what we got +$TGTADM --lld iscsi --mode target --op show + +echo "otgtd started, run up down to stop" From f8d1b4514c882fbe792b1f425416faa5cba72b74 Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Wed, 2 Nov 2011 18:12:22 -0700 Subject: [PATCH 05/10] osc-osd: Make all warnings Errors and have a clean build * Add the -Werror to the flags. We need a clean compilation * Fix a warning in get_mhz() which was actually an error. good catch gcc, thanks Signed-off-by: Boaz Harrosh --- osd-target/Makefile | 2 +- osd-util/osd-util.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osd-target/Makefile b/osd-target/Makefile index 8f868a2..75df94a 100644 --- a/osd-target/Makefile +++ b/osd-target/Makefile @@ -45,7 +45,7 @@ COPTS := $(OPT) COPTS += -fPIC -foptimize-sibling-calls -D_GNU_SOURCE CWARN := -Wall -W -Wpointer-arith -Wwrite-strings -Wcast-align -Wcast-qual \ -Wbad-function-cast -Wundef -Wmissing-prototypes \ - -Wmissing-declarations -Wnested-externs + -Wmissing-declarations -Wnested-externs -Werror CFLAGS += $(COPTS) $(CWARN) -I.. -Wno-unused -I../osd-util ifeq ($(PVFS_OSD_INTEGRATED),1) diff --git a/osd-util/osd-util.c b/osd-util/osd-util.c index 7ad992f..b927d6e 100644 --- a/osd-util/osd-util.c +++ b/osd-util/osd-util.c @@ -693,7 +693,7 @@ double get_mhz(void) fclose(fp); #endif /* else defined(__FreeBSD__) || defined(__APPLE__) */ - return mhz != 0 ?: cpufrequency_not_found ; + return mhz != 0 ? mhz : cpufrequency_not_found ; } /* From 382ac090e2be8833012625b933487dfb19f2e52a Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Wed, 2 Nov 2011 18:21:38 -0700 Subject: [PATCH 06/10] tgt: Force clean builds Integrate latest tgt.git osd-next Signed-off-by: Boaz Harrosh --- tgt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgt b/tgt index 3a36ffa..7c5be90 160000 --- a/tgt +++ b/tgt @@ -1 +1 @@ -Subproject commit 3a36ffaaa41e8eccdc1fcac8fe8ded80771fce61 +Subproject commit 7c5be90639462c731ac21b9e91f4a01dfb90750f From 66b1b25a2d085415294262f8f704365bbac99041 Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Wed, 2 Nov 2011 18:25:04 -0700 Subject: [PATCH 07/10] open-osd: up-pan: Bug fixing, add the stat command tested on actual shelf thsi time. Add the stat command to print UP or DOWN Signed-off-by: Boaz Harrosh --- up-pan | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/up-pan b/up-pan index 90d1ef3..b104f74 100755 --- a/up-pan +++ b/up-pan @@ -1,11 +1,12 @@ -#!/bin/csh -x +#!/bin/csh # On Pan-OSD there is only one target set BACKSTORE0=/root/pandata/ # Path to pan_tgtd executables, assuming p4 integration -dir="/pan/bin" +set dir=/pan/bin set TGTADM=$dir/tgtadm -set OTGTD=$dir/pan_tgtd +set OTGTD_NAME=pan_tgtd +set OTGTD=$dir/$OTGTD_NAME # Get the osd device id set TARGETNAME=`/pan/bin/getdevinfo -q datasn` @@ -14,7 +15,7 @@ set LOG="/var/log/otgtd.log" switch($1) case "down": - killall $OTGTD + killall $OTGTD_NAME exit breaksw @@ -22,11 +23,22 @@ case "log": less +F $LOG exit breaksw + case "log-reset": echo > $LOG exit breaksw +case "stat": + set stat=`ps ax | grep pan_tgtd` + if ( "x${stat}" == "x" ) then + echo "DOWN" + else + echo "UP" + endif + exit + breaksw + default: if ("$1" != "") then echo "what is $0 $1?!?" From 7532f6b3b32f72bd5f4c7f8e20f0c78ebaf4eb8b Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Wed, 2 Nov 2011 20:57:04 -0700 Subject: [PATCH 08/10] tgt: osdemu: Support for Static linking of libsqlite.a [osd-next 6bb84a5] osdemu: Support for Static linking of libsqlite.a 1 files changed, 11 insertions(+), 3 deletions(-) Signed-off-by: Boaz Harrosh --- tgt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgt b/tgt index 7c5be90..6bb84a5 160000 --- a/tgt +++ b/tgt @@ -1 +1 @@ -Subproject commit 7c5be90639462c731ac21b9e91f4a01dfb90750f +Subproject commit 6bb84a5466cd39f780482dfd9cb1a672e8821539 From 99af330549086ace80ff430ddb51b59f4814864d Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Thu, 3 Nov 2011 17:36:02 -0700 Subject: [PATCH 09/10] open-osd: up-pan: Shut up the ln -s complains Second link attempt would fail. Make sure ln does the right thing by adding the -h flag (? RTFM) NOTE: On FreeBSD the flag is -h on Linux its -T go figure Boaz --- up-pan | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/up-pan b/up-pan index b104f74..7da0639 100755 --- a/up-pan +++ b/up-pan @@ -49,7 +49,7 @@ endsw # On Panasas-osd we must make sure that: mkdir -p $BACKSTORE0/ -ln -sf /pandata $BACKSTORE0/dfiles +ln -shf /pandata $BACKSTORE0/dfiles echo "================ `date` =========================" >> $LOG From 1b4b03c776eec64daf08b7ef9b34e06307dba278 Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Tue, 22 May 2012 18:11:43 +0300 Subject: [PATCH 10/10] up: Linux initiator does not like "/" in target name change all "/" to "." in target name. Signed-off-by: Boaz Harrosh --- up | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/up b/up index ffe78ee..cda26f8 100755 --- a/up +++ b/up @@ -32,9 +32,6 @@ TGTADM=./tgt/usr/tgtadm otgtd_name=otgtd OTGTD=./tgt/usr/$otgtd_name -# Make target name the hostname -TARGETNAME="${1//\//\.}$(hostname)" - case $1 in down) killall -s SIGINT $otgtd_name @@ -78,7 +75,10 @@ load_target() { mkdir -p $1/ -$TGTADM --lld iscsi --mode target --op new --tid $2 --targetname="$TARGETNAME"-"$1" +# Make target name the hostname +TARGETNAME="$(hostname)""${1//\//.}" + +$TGTADM --lld iscsi --mode target --op new --tid $2 --targetname="$TARGETNAME" $TGTADM --lld iscsi --mode target \ --op bind --tid $2 --initiator-address ALL