struct obd_export *exp = req->rq_export;
struct obd_device *obd = exp->exp_obd;
struct obd_device *disk_obd;
- struct llog_handle *loghandle;
+ struct llog_handle *loghandle;
struct llogd_body *body;
struct obd_run_ctxt saved;
struct llog_logid *logid = NULL;
struct llog_ctxt *ctxt;
- char * name = NULL;
+ char * name = NULL;
int size = sizeof (*body);
- int rc, rc2;
- ENTRY;
+ int rc, rc2;
+ ENTRY;
body = lustre_swab_reqbuf(req, 0, sizeof(*body),
lustre_swab_llogd_body);
- if (body == NULL) {
+ if (body == NULL) {
CERROR ("Can't unpack llogd_body\n");
GOTO(out, rc =-EFAULT);
- }
+ }
- if (body->lgd_logid.lgl_oid > 0)
+ if (body->lgd_logid.lgl_oid > 0)
logid = &body->lgd_logid;
if (req->rq_reqmsg->bufcount > 1) {
CERROR("Can't unpack name\n");
GOTO(out, rc = -EFAULT);
}
- }
+ }
ctxt = llog_get_context(obd, body->lgd_ctxt_idx);
LASSERT(ctxt != NULL);
disk_obd = ctxt->loc_exp->exp_obd;
- push_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
-
- rc = llog_create(ctxt, &loghandle, logid, name);
- if (rc)
- GOTO(out_pop, rc);
+ push_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
+
+ rc = llog_create(ctxt, &loghandle, logid, name);
+ if (rc)
+ GOTO(out_pop, rc);
rc = lustre_pack_reply(req, 1, &size, NULL);
- if (rc)
+ if (rc)
GOTO(out_close, rc = -ENOMEM);
body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
- body->lgd_logid = loghandle->lgh_id;
+ body->lgd_logid = loghandle->lgh_id;
out_close:
- rc2 = llog_close(loghandle);
- if (!rc)
+ rc2 = llog_close(loghandle);
+ if (!rc)
rc = rc2;
out_pop:
- pop_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
+ pop_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
out:
- RETURN(rc);
+ RETURN(rc);
}
int llog_origin_handle_next_block(struct ptlrpc_request *req)
struct obd_export *exp = req->rq_export;
struct obd_device *obd = exp->exp_obd;
struct obd_device *disk_obd;
- struct llog_handle *loghandle;
+ struct llog_handle *loghandle;
struct llogd_body *body;
struct obd_run_ctxt saved;
struct llog_ctxt *ctxt;
void * ptr;
int size[] = {sizeof (*body),
LLOG_CHUNK_SIZE};
- int rc, rc2;
- ENTRY;
+ int rc, rc2;
+ ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body),
- lustre_swab_llogd_body);
- if (body == NULL) {
+ body = lustre_swab_reqbuf(req, 0, sizeof(*body),
+ lustre_swab_llogd_body);
+ if (body == NULL) {
CERROR ("Can't unpack llogd_body\n");
GOTO(out, rc =-EFAULT);
- }
+ }
OBD_ALLOC(buf, LLOG_CHUNK_SIZE);
if (!buf)
ctxt = llog_get_context(obd, body->lgd_ctxt_idx);
LASSERT(ctxt != NULL);
disk_obd = ctxt->loc_exp->exp_obd;
- push_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
+ push_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
- rc = llog_create(ctxt, &loghandle, &body->lgd_logid, NULL);
- if (rc)
- GOTO(out_pop, rc);
+ rc = llog_create(ctxt, &loghandle, &body->lgd_logid, NULL);
+ if (rc)
+ GOTO(out_pop, rc);
flags = body->lgd_llh_flags;
- rc = llog_init_handle(loghandle, flags, NULL);
- if (rc)
- GOTO(out_close, rc);
+ rc = llog_init_handle(loghandle, flags, NULL);
+ if (rc)
+ GOTO(out_close, rc);
- memset(buf, 0, LLOG_CHUNK_SIZE);
- rc = llog_next_block(loghandle, &body->lgd_saved_index,
+ memset(buf, 0, LLOG_CHUNK_SIZE);
+ rc = llog_next_block(loghandle, &body->lgd_saved_index,
body->lgd_index,
- &body->lgd_cur_offset, buf, LLOG_CHUNK_SIZE);
- if (rc)
- GOTO(out_close, rc);
+ &body->lgd_cur_offset, buf, LLOG_CHUNK_SIZE);
+ if (rc)
+ GOTO(out_close, rc);
rc = lustre_pack_reply(req, 2, size, NULL);
- if (rc)
+ if (rc)
GOTO(out_close, rc = -ENOMEM);
ptr = lustre_msg_buf(req->rq_repmsg, 0, sizeof (body));
- memcpy(ptr, body, sizeof(*body));
+ memcpy(ptr, body, sizeof(*body));
ptr = lustre_msg_buf(req->rq_repmsg, 1, LLOG_CHUNK_SIZE);
- memcpy(ptr, buf, LLOG_CHUNK_SIZE);
+ memcpy(ptr, buf, LLOG_CHUNK_SIZE);
out_close:
- rc2 = llog_close(loghandle);
- if (!rc)
+ rc2 = llog_close(loghandle);
+ if (!rc)
rc = rc2;
out_pop:
- pop_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
+ pop_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
OBD_FREE(buf, LLOG_CHUNK_SIZE);
out:
- RETURN(rc);
+ RETURN(rc);
}
int llog_origin_handle_read_header(struct ptlrpc_request *req)
struct obd_export *exp = req->rq_export;
struct obd_device *obd = exp->exp_obd;
struct obd_device *disk_obd;
- struct llog_handle *loghandle;
+ struct llog_handle *loghandle;
struct llogd_body *body;
struct llog_log_hdr *hdr;
struct obd_run_ctxt saved;
__u32 flags;
__u8 *buf;
int size[] = {sizeof (*hdr)};
- int rc, rc2;
- ENTRY;
+ int rc, rc2;
+ ENTRY;
- body = lustre_swab_reqbuf(req, 0, sizeof(*body),
- lustre_swab_llogd_body);
- if (body == NULL) {
+ body = lustre_swab_reqbuf(req, 0, sizeof(*body),
+ lustre_swab_llogd_body);
+ if (body == NULL) {
CERROR ("Can't unpack llogd_body\n");
GOTO(out, rc =-EFAULT);
- }
+ }
OBD_ALLOC(buf, LLOG_CHUNK_SIZE);
if (!buf)
ctxt = llog_get_context(obd, body->lgd_ctxt_idx);
LASSERT(ctxt != NULL);
disk_obd = ctxt->loc_exp->exp_obd;
- push_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
+ push_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
- rc = llog_create(ctxt, &loghandle, &body->lgd_logid, NULL);
- if (rc)
- GOTO(out_pop, rc);
+ rc = llog_create(ctxt, &loghandle, &body->lgd_logid, NULL);
+ if (rc)
+ GOTO(out_pop, rc);
/* init_handle reads the header */
flags = body->lgd_llh_flags;
- rc = llog_init_handle(loghandle, flags, NULL);
- if (rc)
- GOTO(out_close, rc);
+ rc = llog_init_handle(loghandle, flags, NULL);
+ if (rc)
+ GOTO(out_close, rc);
rc = lustre_pack_reply(req, 1, size, NULL);
- if (rc)
+ if (rc)
GOTO(out_close, rc = -ENOMEM);
hdr = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*hdr));
- memcpy(hdr, loghandle->lgh_hdr, sizeof(*hdr));
+ memcpy(hdr, loghandle->lgh_hdr, sizeof(*hdr));
out_close:
- rc2 = llog_close(loghandle);
- if (!rc)
+ rc2 = llog_close(loghandle);
+ if (!rc)
rc = rc2;
out_pop:
- pop_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
+ pop_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
OBD_FREE(buf, LLOG_CHUNK_SIZE);
out:
- RETURN(rc);
+ RETURN(rc);
}
int llog_origin_handle_close(struct ptlrpc_request *req)
{
- int rc;
+ int rc;
rc = 0;
- RETURN(rc);
+ RETURN(rc);
}
#ifdef ENABLE_ORPHANS
cathandle = ctxt->loc_handle;
LASSERT(cathandle);
- push_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
+ push_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
rc = llog_cat_cancel_records(cathandle, num_cookies, logcookies);
if (rc)
CERROR("cancel %d llog-records failed: %d\n", num_cookies, rc);
--- /dev/null
+#!/bin/sh
+
+# sanity-buffalo.sh
+#
+# This script is used to report the results from a sanity run to buffalo.
+#
+# Assumptions:
+# - the target host on which you are running the test (be it
+# a real machine or a uml session) is accessible via DSH
+
+export TMP=${TMP:-"/tmp"}
+export LOG=${LOG:-"$TMP/sanity-buffalo.log"}
+export DMESGLOG=${DMESGLOG:-"$TMP/sanity-buffalo-dmesg.log"}
+export OUTPUT=${OUTPUT:-"$TMP/buffalo_mail"}
+export DSH=${DSH:-"pdsh -S -w"}
+export LUSTRE_SRC=${LUSTRE_SRC:-"$PWD/.."}
+export LTESTDIR=${LTESTDIR:-"$PWD/../../ltest"}
+export TARGET=${TARGET:-"uml"}
+export SCP=${SCP:-"scp"}
+#export NO_SHARED_FS=0
+
+# Changeable buffalo config variables.
+
+# The following RECIPIENTS string sends results to the buffalo-sandbox.
+RECIPIENTS=${RECIPIENTS:-"buffalo-sandbox@clusterfs.com"}
+# The following RECIPIENTS string sends results to buffalo proper.
+# RECIPIENTS=${RECIPIENTS:-"buffalo_results@clusterfs.com"}
+
+export TESTNAME=${TESTNAME:-"sanity-buffalo"}
+export TESTDESC=${TESTDESC:-"Local test in $TARGET for correctness"}
+export TESTGROUP=${TESTGROUP:-"correctness"}
+export LUSTRE_TAG=${LUSTRE_TAG:-`cat $PWD/CVS/Tag | cut -c 2-`}
+export TESTARCH=${TESTARCH:-`uname -r`}
+export NETWORKTYPE=${NETWORKTYPE:-"tcp"}
+export MACHINENAME=${MACHINENAME:-`hostname`}
+
+usage() {
+
+ echo "echo
+Usage: sanity-buffalo.sh --sender=email_address [--config=config_name] [--test=test_name] [--extra-params=extra_parameters] [--target=hostname] [--help]"
+ if [ x$1 = x-h ]
+ then
+ echo "
+
+--sender=email_address
+ Email address of the person running the test. (Required)
+
+--config=config_name
+ Config type to use for lustre setup. Any of the standard script names
+ from lustre/tests are allowable:
+ lov, local, mount2lov, local-large-inode (default)
+
+--test=test_script
+ Name of the test script to run. Default is \"sanity.sh\".
+
+--target=hostname
+ The machine (or uml session) on which to run the test.
+ Defaults to \"uml\"
+
+--extra-params=extra_parameters
+ Extra parameters to pass to the test script.
+ e.g. --extra-params=\"START=' ' CLEAN=' '\"
+ NOTE: NAME=lov should not be set here, use --config
+
+--help
+ Display this usage message
+
+"
+ exit 0
+ else
+ exit 1
+ fi
+}
+
+check_mail() {
+ if [ -z "$SENDER" ] ; then
+ echo "Please supply a valid email address for --sender"
+ usage
+ fi
+}
+
+check_config() {
+ if [ -z "$CONFIG_NAME" ] ; then
+ echo "Using default config: local-large-inode"
+ CONFIG_NAME="local-large-inode"
+ fi
+}
+
+check_test() {
+ if [ -z "$TESTSCRIPT" ] ; then
+ echo "Running default test: sanity.sh"
+ TESTSCRIPT="sanity.sh"
+ fi
+}
+
+
+do_prepare() {
+ if [ -e $LOG ] ; then
+ rm -fr $LOG
+ fi
+ dmesg -c > /dev/null
+ $DSH $TARGET "dmesg -c > /dev/null" || exit 1
+ return 0
+}
+
+run_test() {
+ $DSH $TARGET "cd $LUSTRE_SRC/tests && PATH=/sbin:/usr/sbin:\$PATH NAME=$CONFIG_NAME sh llmount.sh 2>&1" | dshbak -c >> $LOG
+ if ! [ $? = 0 ] ; then
+ echo "Can not mount lustre on remoute machine: $TARGET "
+ exit 2
+ fi
+ if [ $NO_SHARED_FS ]; then
+ $SCP $TARGET:$LUSTRE_SRC/tests/${CONFIG_NAME}.xml $PWD/config.xml
+ if ! [ $? = 0 ] ; then
+ echo "Can not get the config file from remoute machine: $TARGET "
+ exit 3
+ fi
+ fi
+
+ COMMAND="cd $LUSTRE_SRC/tests && NAME=$CONFIG_NAME PATH=/sbin:/usr/sbin:\$PATH $EXTRA_PARAMS sh $TESTSCRIPT"
+ echo >> $LOG;echo "COMMAND: $COMMAND" >> $LOG;echo >> $LOG
+
+ $DSH $TARGET "$COMMAND 2>&1" | dshbak -c >> $LOG
+ return $?
+}
+
+do_eval() {
+ RC=$1
+
+ if [ $RC -eq 0 ]; then
+ RESULT="pass"
+ else
+ RESULT="fail"
+ fi
+
+ if [ "$RESULT" = "fail" ] ; then
+ $DSH $TARGET "dmesg" | dshbak -c >> $DMESGLOG
+ fi
+}
+
+send_report() {
+ . $LTESTDIR/acceptance/harness/config/common/buffalo.sh
+
+ if [ $NO_SHARED_FS ]; then
+ CONFIG="$PWD/config.xml"
+ else
+ CONFIG="${LUSTRE_SRC}/tests/${CONFIG_NAME}.xml"
+ fi
+ CONFIGDESC=${CONFIGDESC:-"${TARGET}-${CONFIG_NAME}"}
+
+ ### send buffalo reports
+ echo "Sending buffalo report..."
+ rm -fr $OUTPUT
+ buffalo_format_result > $OUTPUT
+ buffalo_format_config $CONFIG >> $OUTPUT
+ buffalo_format_log $LOG >> $OUTPUT
+ buffalo_format_dmesg $DMESGLOG >> $OUTPUT
+ buffalo_send_report $OUTPUT
+ rm -f $OUTPUT
+ rm -f $DMESGLOG
+ rm -f $LOG
+ echo "done."
+}
+
+do_cleanup() {
+ $DSH $TARGET "cd $LUSTRE_SRC/tests && NAME=$CONFIG_NAME sh llmountcleanup.sh 2>&1" | dshbak -c >> $LOG
+ if ! [ $? = 0 ] ; then
+ echo "failed to clean up lustre"
+ fi
+}
+
+options=`getopt -o h --long extra-params:,target:,sender:,config:,test:,help -- "$@"`
+
+if [ $? -ne 0 ] ; then
+ usage
+fi
+eval set -- "$options"
+while true
+ do
+ case "$1" in
+ --config)
+ CONFIG_NAME=$2
+ shift 2 ;;
+ --sender)
+ SENDER=$2
+ shift 2 ;;
+ --target)
+ TARGET=$2
+ shift 2 ;;
+ --extra-params)
+ EXTRA_PARAMS=$2
+ shift 2 ;;
+ --test)
+ TESTSCRIPT=$2
+ shift 2 ;;
+ --help)
+ usage -h ;;
+ -h)
+ usage -h ;;
+ --)
+ shift
+ break ;;
+ esac
+done
+
+if [ ! -d ${LUSTRE_SRC} ]; then
+ echo "LUSTRE_SRC dir $LUSTRE_SRC doesn't exist"
+ exit 1
+fi
+
+if [ ! -d ${LTESTDIR} ]; then
+ echo "LTESTDIR dir $LTESTDIR doesn't exist"
+ exit 2
+fi
+
+# Gather some buffalo variable before we run the test.
+export KERNEL=`$DSH $TARGET uname -r | sed "s/^.*\ //g"`
+export LUSTRE_BUILD=`${LUSTRE_SRC}/utils/lctl lustre_build_version 2>/dev/null|grep "^lctl" | awk '/^lctl/ {print $3}'`
+
+check_mail && check_config && check_test
+
+do_prepare
+run_test
+do_eval $?
+do_cleanup
+
+send_report
+
+exit 0
+
+