X-Git-Url: https://code.grnet.gr/git/archipelago/blobdiff_plain/a5c1eefbe2b6b6501e998e8adf6e8c617c9d8387..f29c3bebd18166d63d26c8014e7f1ea2bfbbb8f0:/xseg/launch?ds=sidebyside diff --git a/xseg/launch b/xseg/launch index e7f8c7e..2fae9b2 100755 --- a/xseg/launch +++ b/xseg/launch @@ -7,6 +7,8 @@ export NONINTERACTIVE=1 source envsetup export NONINTERACTIVE=${NI_SAVED} +set +e + function pretty_print { echo "=======================" echo "$1" @@ -24,21 +26,30 @@ function parse_config { [ -z "${HOSTNAME}" ] && HOSTNAME=`hostname` [ -z "${XSEG_HOME}" ] && XSEG_HOME="/root/archip/xseg" [ -z "${MODULES_DIR}" ] && MODULES_DIR="${XSEG_HOME}/lib/kernel" - #type:name:nr_ports:nr_requests:request_size:extra_size:page_shift - [ -z "${SPEC}" ] && SPEC="segdev:xsegbd:4:1024:12" + [ -z "${SPEC}" ] && SPEC="segdev:xsegbd:512:1024:12" [ -z "${REQS}" ] && REQS=512 - [ -z "${PORTS}" ] && PORTS=16 - [ -z "${IMAGES}" ] && IMAGES="/srv/archip/images" - [ -z "${XSEG_LOGS}" ] && BLOCKD_LOGS="/srv/archip/logs" + [ -z "${PORTS}" ] && PORTS=512 + [ -z "${IMAGES}" ] && IMAGES="/home/user/archip/xseg/peers/user/foo" + [ -z "${MAPS}" ] && MAPS="/home/user/archip/xseg/peers/user/foo" + [ -z "${PITHOS}" ] && PITHOS="/srv/pithos/data/blocks" + [ -z "${PITHOSMAPS}" ] && PITHOSMAPS="/srv/pithos/data/maps" + [ -z "${XSEG_LOGS}" ] && XSEG_LOGS="/home/philipgian/archip/logs" [ -z "${DEVICE_PREFIX}" ] && DEVICE_PREFIX="/dev/xsegbd" [ -z "${XSEGBD_SYSFS}" ] && XSEGBD_SYSFS="/sys/bus/xsegbd" - [ -z "${CHRDEV_NAME}" ] && CHRDEV_NAME=/dev/`cat /proc/devices | grep segdev | awk '{print $2}'` + [ -z "${CHRDEV_NAME}" ] && CHRDEV_NAME="/dev/`cat /proc/devices | grep segdev | awk '{print $2}'`" [ "${CHRDEV_NAME}" = "/dev/" ] && CHRDEV_NAME="/dev/segdev" [ -z "${CHRDEV_MAJOR}" ] && CHRDEV_MAJOR=`cat /proc/devices | grep segdev | awk '{print $1}'` [ -z "${CHRDEV_MAJOR}" ] && CHRDEV_MAJOR=60 - [ -z "${NR_OPS}" ] && NR_OPS=16 + [ -z "${NR_OPS}" ] && NR_OPS=128 + [ -z "${BPORT}" ] && BPORT=0 + [ -z "${VPORT_START}" ] && VPORT_START=4 + [ -z "${VPORT_END}" ] && VPORT_END=200 + [ -z "${MPORT}" ] && MPORT=1 + [ -z "${MBPORT}" ] && MBPORT=2 + [ -z "${VTOOL}" ] && VTOOL=3 } + function unload_module { rmmod "$1" } @@ -47,8 +58,8 @@ function unload_all { unload_module "xsegbd" rm "${CHRDEV_NAME}" || true unload_module "xseg_segdev" - unload_module "xseg_pthread" unload_module "xseg_posix" + unload_module "xseg_pthread" unload_module "segdev" unload_module "xseg" } @@ -69,17 +80,63 @@ function load_all { load_module "xseg_pthread" load_module "xseg_segdev" mk_chardev - "${XSEG_HOME}/peers/user/xseg" "${SPEC}" create + "${XSEG_HOME}/peers/user/xseg" "${SPEC}" create || true load_module "xsegbd" "spec=$SPEC" } -# spawn_filed - Spawn a filed instance -# -# @param $1 root directory -# @param $2 xseg port +function create_segment { + "${XSEG_HOME}/peer/users/xseg" "${SPEC}" create +} + +function destroy_segment { + "${XSEG_TOOL}" "${SPEC}" destroy +} + +function alloc_requests { + "${XSEG_TOOL}" "${SPEC}" $1 alloc_requests $2 +} + +function free_requests { + "${XSEG_TOOL}" "${SPEC}" $1 free_requests $2 +} function spawn_filed { - "${XSEG_HOME}/peers/user/filed" "$1" -p "$2" -g "${SPEC}" -n ${NR_OPS} -v > "${XSEG_LOGS}/filed-${HOSTNAME}" 2>&1 & + pgrep -f "peers/user/filed" || \ + "${XSEG_HOME}/peers/user/filed" "$IMAGES" -p "$BPORT" -g "${SPEC}" -n \ + ${NR_OPS} &> "${XSEG_LOGS}/filed-${HOSTNAME}" & +} + +function spawn_pfiled { + "${XSEG_HOME}/peers/user/pfiled" -p "$BPORT" -g "${SPEC}" -n \ + ${NR_OPS} "${PITHOS}" "${IMAGES}" -v 1 &> "${XSEG_LOGS}/pfiled-${HOSTNAME}" & +} + +function spawn_pfiledm { + "${XSEG_HOME}/peers/user/pfiled" -p "$MBPORT" -g "${SPEC}" -n \ + ${NR_OPS} "${PITHOSMAPS}" "${MAPS}" -v 1 &> "${XSEG_LOGS}/pfiledm-${HOSTNAME}" & +} + +function spawn_vlmcd { + pgrep -f "peers/user/st-vlmcd" || \ + "${XSEG_HOME}/peers/user/st-vlmcd" -t 1 -sp "$VPORT_START" \ + -ep "$VPORT_END" -bp "$BPORT" -mp "$MPORT" -g \ + "${SPEC}" -n ${NR_OPS} -v 3 &> "${XSEG_LOGS}/vlmcd-${HOSTNAME}" & +# alloc_requests "$VPORT:0" 128 +} + +function spawn_mapperdc { + pgrep -f "mt-mapperd" || \ + "${XSEG_HOME}/peers/user/mt-mapperd" -t 1 -sp "$MPORT" -ep "$MPORT"\ + -bp "$BPORT" -mbp "$MBPORT" -g "${SPEC}"\ + -n ${NR_OPS} -v 3 &> "${XSEG_LOGS}/mapperd-${HOSTNAME}" & +# alloc_requests "$MPORT:0" 128 +} + +function spawn_mapperd { + pgrep -f "mapperd.py" || \ + "${XSEG_HOME}/peers/user/mapperd.py" -p "$MPORT" -b "$BPORT" -g "${SPEC}" \ + &> "${XSEG_LOGS}/mapperd-${HOSTNAME}" & +# alloc_requests "$MPORT:0" 128 } # map_volume - Map a volume to an xsegbd device @@ -107,10 +164,12 @@ if [ -n "$NONINTERACTIVE" ]; then fi parse_config +XSEG_TOOL="${XSEG_HOME}/peers/user/xseg" case $1 in list) echo "filed [start|stop]" + echo "map [start|stap]" echo " " echo "insmod" echo "rmmod" @@ -131,27 +190,50 @@ config) echo "REQS=${REQS}" echo "PORTS=${PORTS}" echo "IMAGES=${IMAGES}" + echo "PITHOS=${PITHOS}" echo "XSEG_LOGS=${XSEG_LOGS}" echo "DEVICE_PREFIX=${DEVICE_PREFIX}" echo "XSEGBD_SYSFS=${XSEGBD_SYSFS}" echo "CHRDEV_NAME=${CHRDEV_NAME}" echo "CHRDEV_MAJOR=${CHRDEV_MAJOR}" echo "NR_OPS=${NR_OPS}" + echo "BPORT=${BPORT}" + echo "VPORT=${VPORT}" + echo "MPORT=${MPORT}" ;; filed) case $2 in start) - mk_chardev load_all - spawn_filed ${IMAGES} 1 - sleep 1 - map_volume xsegvol 0 1 + sleep 0.5 + spawn_filed + sleep 0.5 + map_volume xsegvol 3 0 ;; stop) pkill -f peers/user/filed sleep 0.5 - unmap_device 0 - rm ${CHRDEV_NAME} + unmap_device 3 + unload_all + ;; + esac + ;; +map) + case $2 in + start) + load_all + sleep 0.5 + spawn_pfiled + spawn_mapperd + spawn_vlmcd + ;; + stop) + pkill -f peers/user/mt-vlmcd || true +# free_requests "$VPORT:0" 128 || true + pkill -f peers/user/mt-mapperd || true +# free_requests "$MPORT:0" 128 || true + pkill -f peers/user/pfiled || true + sleep 0.5 unload_all ;; *) @@ -159,8 +241,86 @@ filed) ;; esac ;; +nomodules) + case $2 in + start) + spawn_filed + spawn_mapperd + spawn_vlmcd + ;; + stop) + pkill -f peers/user/mt-vlmcd || true +# free_requests "$VPORT:0" 128 || true + pkill -f peers/user/mt-mapperd || true +# free_requests "$MPORT:0" 128 || true + pkill -f peers/user/filed || true + ;; + *) + help + ;; + esac + ;; +one) + case $2 in + start) + load_all + sleep 1 + spawn_filed + spawn_mapperdc + spawn_vlmcd + ;; + stop) + pkill -f peers/user/mt-vlmcd || true +# free_requests "$VPORT:0" 128 || true + pkill -f peers/user/mt-mapperd || true +# free_requests "$MPORT:0" 128 || true + pkill -f peers/user/filed || true + sleep 0.5 + unload_all + ;; + *) + help + ;; + esac + ;; +doublemap) + case $2 in + start) + load_all + sleep 0.5 + spawn_pfiled + spawn_pfiledm + spawn_mapperdc + spawn_vlmcd + ;; + stop) + pkill -f peers/user/st-vlmcd || true +# free_requests "$VPORT:0" 128 || true + pkill -f peers/user/mt-mapperd || true +# free_requests "$MPORT:0" 128 || true + pkill -f peers/user/pfiled || true + sleep 0.5 + unload_all + ;; + *) + help + ;; + esac + ;; +mapperd) + case $2 in + start) + spawn_mapperdc + ;; + stop) + pkill -f peers/user/mt-mapperd || true + ;; + *) + help + ;; + esac + ;; *) help ;; esac -