From: alex Date: Mon, 2 Aug 2004 23:39:02 +0000 (+0000) Subject: b=4059 X-Git-Tag: v1_7_100~2004 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=dd45d380ec5452cfcea1d80d6409596cea5cafdb;hp=6d59df8db7ab97218965a6fd96c8f3c9c0653d03;p=fs%2Flustre-release.git b=4059 - race in lmv_check_connect() has been fixed: few threads might try to establish LMV's connects to MDCs and some of them might find not-yet- -connected LMV operational --- diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index 94616f8..56eab77 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -450,6 +450,7 @@ struct lmv_obd { int max_cookiesize; int server_timeout; int connect_flags; + struct semaphore init_sem; }; struct niobuf_local { diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 9d6aab1..66d9d7f 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -197,6 +197,7 @@ static int lmv_connect(struct lustre_handle *conn, struct obd_device *obd, lmv->connect_flags = connect_flags; lmv->connected = 0; lmv->exp = exp; + sema_init(&lmv->init_sem, 1); RETURN(0); } @@ -233,7 +234,13 @@ int lmv_check_connect(struct obd_device *obd) if (lmv->connected) return 0; - + + down(&lmv->init_sem); + if (lmv->connected) { + up(&lmv->init_sem); + return 0; + } + lmv->connected = 1; cluuid = &lmv->cluuid; exp = lmv->exp; @@ -302,6 +309,7 @@ int lmv_check_connect(struct obd_device *obd) lmv_set_timeouts(obd); class_export_put(exp); + up(&lmv->init_sem); return 0; out_disc: @@ -318,6 +326,7 @@ int lmv_check_connect(struct obd_device *obd) "error %d\n", uuid.uuid, i, rc2); } class_disconnect(exp, 0); + up(&lmv->init_sem); RETURN (rc); }