From 3d11b21623f3f2194bf890994e88491310171c42 Mon Sep 17 00:00:00 2001 From: ericm Date: Fri, 27 Oct 2006 18:13:30 +0000 Subject: [PATCH] branch: b1_8 merge from b1_5 (20061027_1139) --- lustre/scripts/lc_lvm.sh.in | 40 +++++++++++++++++++++++--- lustre/scripts/lc_net.sh.in | 68 ++++++++++++++++++++++++++------------------- lustre/utils/lr_reader.c | 8 +++--- 3 files changed, 79 insertions(+), 37 deletions(-) diff --git a/lustre/scripts/lc_lvm.sh.in b/lustre/scripts/lc_lvm.sh.in index 64018d2..6d9f7e5 100644 --- a/lustre/scripts/lc_lvm.sh.in +++ b/lustre/scripts/lc_lvm.sh.in @@ -10,11 +10,17 @@ usage() { cat >&2 < +Usage: `basename $0` [options] This script is used to configure Linux LVM devices in a Lustre cluster from a csv file. + Options: + -a select all the nodes from the csv file to operate on + -w hostname,hostname,... + select the specified list of nodes (separated by commas) + -x hostname,hostname,... + exclude the specified list of nodes (separated by commas) -h help and examples -v verbose mode csv file a spreadsheet that contains configuration parameters @@ -126,8 +132,20 @@ declare -i pid_num=0 VERBOSE_OUTPUT=false # Get and check the positional parameters -while getopts "hv" OPTION; do +while getopts "aw:x:hv" OPTION; do case $OPTION in + a) + [ -z "${SPECIFIED_NODELIST}" ] && [ -z "${EXCLUDED_NODELIST}" ] \ + && USE_ALLNODES=true + ;; + w) + USE_ALLNODES=false + SPECIFIED_NODELIST=$OPTARG + ;; + x) + USE_ALLNODES=false + EXCLUDED_NODELIST=$OPTARG + ;; h) sample ;; @@ -225,6 +243,7 @@ get_lvm_items() { CSV_FILE=$1 local LINE line_marker + local hostname declare -i line_num=0 declare -i idx=0 @@ -235,11 +254,17 @@ get_lvm_items() { [ -z "`echo \"${LINE}\" | egrep -v \"([[:space:]]|^)#\"`" ] && continue # Skip the non-LVM line - line_marker=`echo ${LINE} | awk -F, '{print $2}'` + line_marker=$(echo ${LINE} | cut -d, -f 2) [ "${line_marker}" != "${PV_MARKER}" ] \ && [ "${line_marker}" != "${VG_MARKER}" ] \ && [ "${line_marker}" != "${LV_MARKER}" ] && continue + # Skip the host which is not specified in the host list + if ! ${USE_ALLNODES}; then + hostname=$(echo ${LINE} | cut -d, -f 1) + ! host_in_hostlist ${hostname} ${NODES_TO_USE} && continue + fi + # Parse the config line into CONFIG_ITEM if ! parse_line "$LINE"; then return 1 @@ -527,7 +552,7 @@ config_lvm() { failed_status=false for ((pid_num = 0; pid_num < ${#REMOTE_PID[@]}; pid_num++)); do wait ${REMOTE_PID[${pid_num}]} - if [ $? -ne 0 ]; then + if [ ${PIPESTATUS[0]} -ne 0 ]; then echo >&2 "`basename $0`: config_lvm() error: Failed"\ "to execute \"${REMOTE_CMD[${pid_num}]}\"!" failed_status=true @@ -548,6 +573,13 @@ if ! check_file $1; then exit 1 fi +# Get the list of nodes to be operated on +NODES_TO_USE=$(get_nodelist) +[ ${PIPESTATUS[0]} -ne 0 ] && echo >&2 "${NODES_TO_USE}" && exit 1 + +# Check the node list +check_nodelist ${NODES_TO_USE} || exit 1 + # Get all the LVM device items from the csv file if ! get_lvm_items ${CSV_FILE}; then exit 1 diff --git a/lustre/scripts/lc_net.sh.in b/lustre/scripts/lc_net.sh.in index e4f150c..4bc889f 100644 --- a/lustre/scripts/lc_net.sh.in +++ b/lustre/scripts/lc_net.sh.in @@ -8,8 +8,14 @@ usage() { cat >&2 < - +Usage: `basename $0` [options] + + Options: + -a select all the nodes from the csv file to operate on + -w hostname,hostname,... + select the specified list of nodes (separated by commas) + -x hostname,hostname,... + exclude the specified list of nodes (separated by commas) -v verbose mode csv file a spreadsheet that contains configuration parameters (separated by commas) for each target in a Lustre cl- @@ -25,8 +31,20 @@ EOF VERBOSE_OUTPUT=false # Get and check the positional parameters -while getopts "v" OPTION; do +while getopts "aw:x:v" OPTION; do case $OPTION in + a) + [ -z "${SPECIFIED_NODELIST}" ] && [ -z "${EXCLUDED_NODELIST}" ]\ + && USE_ALLNODES=true + ;; + w) + USE_ALLNODES=false + SPECIFIED_NODELIST=$OPTARG + ;; + x) + USE_ALLNODES=false + EXCLUDED_NODELIST=$OPTARG + ;; v) VERBOSE_OUTPUT=true ;; @@ -49,34 +67,26 @@ CSV_FILE=$1 declare -a HOST_NAMES declare -a HOST_IPADDRS -# Get the host names from the csv file +# Get the hosts to be operated on get_hostnames() { - local NAME CHECK_STR - declare -i i - declare -i j + local NODES_TO_USE # Initialize the HOST_NAMES array unset HOST_NAMES - CHECK_STR=`egrep -v "([[:space:]]|^)#" ${CSV_FILE} | awk -F, \ - '/[[:alnum:]]/{if ($1 !~/[[:alnum:]]/) print $0}'` - if [ -n "${CHECK_STR}" ]; then - echo >&2 $"`basename $0`: get_hostnames() error: Missing"\ - "hostname field in the line - ${CHECK_STR}" + # Get the list of nodes to be operated on + NODES_TO_USE=$(get_nodelist) + [ ${PIPESTATUS[0]} -ne 0 ] && echo >&2 "${NODES_TO_USE}" && return 1 + + # Check the node list + if [ -z "${NODES_TO_USE}" ]; then + echo "`basename $0`: There are no hosts to be operated on."\ + "Check the node selection options (-a, -w or -x)." return 1 fi - i=0 - for NAME in `egrep -v "([[:space:]]|^)#" ${CSV_FILE}\ - | awk -F, '/[[:alnum:]]/{print $1}'` - do - for ((j = 0; j < ${#HOST_NAMES[@]}; j++)); do - [ "${NAME}" = "${HOST_NAMES[j]}" ] && continue 2 - done - - HOST_NAMES[i]=${NAME} - i=$i+1 - done + # Load the hostnames in the nodelist into the array + HOST_NAMES=( $(echo ${NODES_TO_USE//,/ }) ) return 0 } @@ -95,8 +105,8 @@ ping_host() { fi # Run ping command - ret_str=`ping -c1 ${host_name} 2>&1` - if [ $? -ne 0 ]; then + ret_str=$(ping -c1 ${host_name} 2>&1) + if [ ${PIPESTATUS[0]} -ne 0 ]; then if [ -n "${ret_str}" ]; then echo "`basename $0`: ping_host() error: ${ret_str}!" else @@ -122,7 +132,7 @@ local_check() { # Check whether ${HOST_NAMES[i]} is reachable # and get the IP address of this host from ping HOST_IPADDRS[i]=$(ping_host ${HOST_NAMES[i]}) - if [ $? -ne 0 ]; then + if [ ${PIPESTATUS[0]} -ne 0 ]; then echo >&2 "${HOST_IPADDRS[i]}" return 1 fi @@ -141,8 +151,8 @@ remote_check() { # Execute remote command to check whether ${HOST_NAMES[i]} # can resolve its own name cmd="ping -c1 ${HOST_NAMES[i]} 2>&1" - ret_str=`${REMOTE} ${HOST_NAMES[i]} "${cmd}" 2>&1` - if [ $? -ne 0 -a -n "${ret_str}" ]; then + ret_str=$(${REMOTE} ${HOST_NAMES[i]} "${cmd}" 2>&1) + if [ ${PIPESTATUS[0]} -ne 0 -a -n "${ret_str}" ]; then echo >&2 "`basename $0`: remote_check() error:"\ "remote to ${HOST_NAMES[i]} error: ${ret_str}!" return 1 @@ -185,7 +195,7 @@ network_verify() { # Initialize the HOST_IPADDRS array unset HOST_IPADDRS - # Get all the host names from the csv file + # Get all the host names to be operated on ! get_hostnames && return 1 # Check the network connectivity between local host diff --git a/lustre/utils/lr_reader.c b/lustre/utils/lr_reader.c index 32a66e1..f1275b3 100644 --- a/lustre/utils/lr_reader.c +++ b/lustre/utils/lr_reader.c @@ -121,17 +121,17 @@ int main(int argc, char *const argv[]) ret = -errno; goto out_rmdir; } - + printf("Reading %s\n", LAST_RCVD); ret = fread(&lsd, 1, sizeof(lsd), filep); if (ret < sizeof(lsd)) { fprintf(stderr, "%s: Short read (%d of %d)\n", - progname, ret, sizeof(lsd)); + progname, ret, (int)sizeof(lsd)); ret = -ferror(filep); if (ret) goto out_close; } - + #if 0 __u8 lsd_uuid[40]; /* server UUID */ __u64 lsd_last_transno; /* last completed transaction ID */ @@ -156,7 +156,7 @@ int main(int argc, char *const argv[]) printf("Feature compat=%#x\n", lsd.lsd_feature_compat); printf("Feature incompat=%#x\n", lsd.lsd_feature_incompat); printf("Feature rocompat=%#x\n", lsd.lsd_feature_rocompat); - printf("Last transaction %llu\n", lsd.lsd_last_transno); + printf("Last transaction %llu\n", (long long)lsd.lsd_last_transno); printf("ost index %u\n", lsd.lsd_ost_index); printf("mdt index %u\n", lsd.lsd_mdt_index); -- 1.8.3.1