From: Bobi Jam Date: Mon, 28 Jan 2013 12:29:31 +0000 (+0800) Subject: LU-642 lov: make up obd_connect for inactive OSC X-Git-Tag: 2.3.61~10 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=20af79d52e2c724dd7e665258432ddce758eb04d LU-642 lov: make up obd_connect for inactive OSC When OSC is inactivated before lov tries to connect it, lov_connect() miss the chance to connect it to OST devices even when it is activated later. We need make up the connection for the initially inactive OSC when it is activated. Signed-off-by: Bobi Jam Change-Id: I4aca442bc4a77baa2bc14adaf2b0f8f5c7bfa7df Reviewed-on: http://review.whamcloud.com/4691 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 85f0fec..31cb5bb 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -488,12 +488,12 @@ int client_connect_import(const struct lu_env *env, struct obd_device *obd, struct obd_uuid *cluuid, struct obd_connect_data *data, void *localdata) { - struct client_obd *cli = &obd->u.cli; - struct obd_import *imp = cli->cl_import; - struct obd_connect_data *ocd; - struct lustre_handle conn = { 0 }; - int rc; - ENTRY; + struct client_obd *cli = &obd->u.cli; + struct obd_import *imp = cli->cl_import; + struct obd_connect_data *ocd; + struct lustre_handle conn = { 0 }; + int rc; + ENTRY; *exp = NULL; down_write(&cli->cl_sem); @@ -547,7 +547,7 @@ out_ldlm: out_sem: up_write(&cli->cl_sem); - return rc; + return rc; } EXPORT_SYMBOL(client_connect_import); diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 19c424c..9d78609 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -388,11 +388,24 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, CDEBUG(D_INFO, "Searching in lov %p for uuid %s event(%d)\n", lov, uuid->uuid, ev); - obd_getref(obd); - for (index = 0; index < lov->desc.ld_tgt_count; index++) { - tgt = lov->lov_tgts[index]; - if (!tgt || !tgt->ltd_exp) - continue; + obd_getref(obd); + for (index = 0; index < lov->desc.ld_tgt_count; index++) { + tgt = lov->lov_tgts[index]; + if (!tgt) + continue; + /* + * LU-642, initially inactive OSC could miss the obd_connect, + * we make up for it here. + */ + if (ev == OBD_NOTIFY_ACTIVATE && tgt->ltd_exp == NULL && + obd_uuid_equals(uuid, &tgt->ltd_uuid)) { + struct obd_uuid lov_osc_uuid = {"LOV_OSC_UUID"}; + + obd_connect(NULL, &tgt->ltd_exp, tgt->ltd_obd, + &lov_osc_uuid, &lov->lov_ocd, NULL); + } + if (!tgt->ltd_exp) + continue; CDEBUG(D_INFO, "lov idx %d is %s conn "LPX64"\n", index, obd_uuid2str(&tgt->ltd_uuid), diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c index 29fbebc5..0f3f6f8 100644 --- a/lustre/osc/lproc_osc.c +++ b/lustre/osc/lproc_osc.c @@ -68,14 +68,12 @@ static int osc_wr_active(struct file *file, const char *buffer, if (val < 0 || val > 1) return -ERANGE; - LPROCFS_CLIMP_CHECK(dev); /* opposite senses */ if (dev->u.cli.cl_import->imp_deactive == val) rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val); else CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n", val); - LPROCFS_CLIMP_EXIT(dev); return count; } diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 0a84732..5aeec40 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -2782,6 +2782,42 @@ test_50g() { } run_test 50g "deactivated OST should not cause panic=====================" +# LU-642 +test_50h() { + # prepare MDT/OST, make OSC inactive for OST1 + [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return + do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" || + error "tunefs OST1 failed" + start_mds || error "Unable to start MDT" + start_ost || error "Unable to start OST1" + start_ost2 || error "Unable to start OST2" + mount_client $MOUNT || error "client start failed" + + mkdir -p $DIR/$tdir + + # activatate OSC for OST1 + local TEST="$LCTL get_param -n osc.${FSNAME}-OST0000-osc-[!M]*.active" + set_conf_param_and_check client \ + "$TEST" "${FSNAME}-OST0000.osc.active" 1 || + error "Unable to activate OST1" + + mkdir -p $DIR/$tdir/2 + $LFS setstripe -c -1 -i 0 $DIR/$tdir/2 + sleep 1 && echo "create a file after OST1 is activated" + # create some file + createmany -o $DIR/$tdir/2/$tfile-%d 1 + + # check OSC import is working + stat $DIR/$tdir/2/* >/dev/null 2>&1 || + error "some OSC imports are still not connected" + + # cleanup + umount_client $MOUNT || error "Unable to umount client" + stop_ost2 || error "Unable to stop OST2" + cleanup_nocli +} +run_test 50h "LU-642: activate deactivated OST ===" + test_51() { local LOCAL_TIMEOUT=20