Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of git://git.open-osd.org/osc-osd
  • Loading branch information
joc02012 committed May 24, 2012
2 parents 116948f + 1b4b03c commit 8fbc402
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 33 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -36,7 +36,7 @@ old-tars
patches

#
# programs & Tests
# programs, Tests & logs
#
osd-initiator/tests/alignment
osd-initiator/tests/atomic
Expand All @@ -62,6 +62,8 @@ osd-target/tests/list
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
Expand Down
2 changes: 1 addition & 1 deletion osd-target/Makefile
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions osd-target/cdb.h
Expand Up @@ -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 */
17 changes: 17 additions & 0 deletions osd-target/osd.c
Expand Up @@ -1087,6 +1087,22 @@ out:
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;
Expand Down Expand Up @@ -2516,6 +2532,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;
Expand Down
2 changes: 1 addition & 1 deletion osd-util/osd-util.c
Expand Up @@ -693,7 +693,7 @@ no_cpufrequency:
fclose(fp);
#endif /* else defined(__FreeBSD__) || defined(__APPLE__) */

return mhz != 0 ?: cpufrequency_not_found ;
return mhz != 0 ? mhz : cpufrequency_not_found ;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion tgt
Submodule tgt updated from 91122c to 6bb84a
115 changes: 86 additions & 29 deletions 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

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/

# 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

Expand 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"
78 changes: 78 additions & 0 deletions up-pan
@@ -0,0 +1,78 @@
#!/bin/csh

# On Pan-OSD there is only one target
set BACKSTORE0=/root/pandata/
# Path to pan_tgtd executables, assuming p4 integration
set dir=/pan/bin
set TGTADM=$dir/tgtadm
set OTGTD_NAME=pan_tgtd
set OTGTD=$dir/$OTGTD_NAME

# 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_NAME
exit
breaksw

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?!?"
exit
endif
breaksw
endsw

# On Panasas-osd we must make sure that:
mkdir -p $BACKSTORE0/
ln -shf /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"

0 comments on commit 8fbc402

Please sign in to comment.