From b1e14ba77d971c8719397cbe10e43b4e85f41765 Mon Sep 17 00:00:00 2001 From: bobijam Date: Mon, 29 Jun 2009 01:44:23 +0000 Subject: [PATCH] Branch b_release_1_8_1 b=18478 i=zhen.liang i=johann Fix obdecho to make it work. --- lustre/obdecho/echo_client.c | 33 ++++++++++++++++++++++++++++----- lustre/tests/sanity.sh | 23 ++++++++++++++++++++++- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 8ed0815..b079a36 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -1314,25 +1314,48 @@ echo_client_setup(struct obd_device *obddev, obd_count len, void *buf) CFS_INIT_LIST_HEAD (&ec->ec_objects); ec->ec_unique = 0; + ec->ec_exp = lustre_hash_lookup(tgt->obd_uuid_hash, &echo_uuid); + if (ec->ec_exp) + RETURN(0); + OBD_ALLOC(ocd, sizeof(*ocd)); if (ocd == NULL) { CERROR("Can't alloc ocd connecting to %s\n", lustre_cfg_string(lcfg, 1)); return -ENOMEM; } - ocd->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_REQPORTAL; ocd->ocd_version = LUSTRE_VERSION_CODE; - rc = obd_connect(&conn, tgt, &echo_uuid, ocd, &ec->ec_exp); + if ((strncmp(tgt->obd_type->typ_name, LUSTRE_OSC_NAME, + strlen(LUSTRE_OSC_NAME)) == 0) || + (strncmp(tgt->obd_type->typ_name, LUSTRE_LOV_NAME, + strlen(LUSTRE_LOV_NAME)) == 0)) { + rc = obd_connect(&conn, tgt, &echo_uuid, ocd, &ec->ec_exp); + } else { + rc = obd_connect(&conn, tgt, &echo_uuid, ocd, NULL); + if (rc == 0) + ec->ec_exp = class_conn2export(&conn); + } OBD_FREE(ocd, sizeof(*ocd)); - if (rc != 0) { + if (rc == -EALREADY && (strncmp(tgt->obd_type->typ_name,LUSTRE_OSC_NAME, + strlen(LUSTRE_OSC_NAME)) == 0)) { + /* OSC obd forbid reconnect already connected import, + * so we hack creating another export here */ + down_write(&tgt->u.cli.cl_sem); + rc = class_connect(&conn, tgt, &echo_uuid); + if (rc == 0) { + ++tgt->u.cli.cl_conn_count; + ec->ec_exp = class_conn2export(&conn); + } + up_write(&tgt->u.cli.cl_sem); + } + + if (rc != 0) CERROR("fail to connect to device %s\n", lustre_cfg_string(lcfg, 1)); - return (rc); - } RETURN(rc); } diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 5232f05..6f9a70b 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -3876,7 +3876,7 @@ test_101d() { local ra_MB=${READAHEAD_MB:-40} local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }') - [ $space -gt $((size / 1024)) ] || + [ $space -gt $((size / 1024)) ] || { skip "Need free space ${size}M, have $space" && return; } echo Creating ${size}M test file $file @@ -5911,6 +5911,27 @@ test_170() { } run_test 170 "test lctl df to handle corrupted log =====================" +obdecho_create_test() { + local OBD=$1 + $LCTL attach echo_client ec ec_uuid || return 1 + $LCTL --device ec setup $OBD || return 2 + $LCTL --device ec create 1 || return 3 + $LCTL --device ec cleanup || return 4 + $LCTL --device ec detach || return 5 +} + +test_180() { + load_module obdecho/obdecho + + local OBD=`$LCTL dl | awk ' /obdfilter/ { print $4; exit; }'` + obdecho_create_test $OBD + + OBD=`$LCTL dl | awk ' /-osc-/ { print $4; exit; }'` + obdecho_create_test $OBD + rmmod obdecho +} +run_test 180 "test obdecho ============================================" + POOL=${POOL:-cea1} TGT_COUNT=$OSTCOUNT -- 1.8.3.1