From 525d2ae7a855a2097ed1648c5b0232544362a5a0 Mon Sep 17 00:00:00 2001 From: adilger Date: Sat, 23 Nov 2002 02:23:10 +0000 Subject: [PATCH] Fix the many client simultaneous startup bug (b=392). We just ignore exports with NULL mcd, since they are just being set up. The clients have a semaphore to prevent multiple setups there. We could alternately have a semaphore on the MDS instead of the current spinlock. --- lustre/mds/handler.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 24dadaf..7dd8ad1 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -298,6 +298,10 @@ static int mds_connect(struct lustre_handle *conn, struct obd_device *obd, list_for_each(p, &obd->obd_exports) { exp = list_entry(p, struct obd_export, exp_obd_chain); mcd = exp->exp_mds_data.med_mcd; + if (!mcd) { + CERROR("FYI: NULL mcd - simultaneous connects\n"); + continue; + } if (!memcmp(cluuid, mcd->mcd_uuid, sizeof(mcd->mcd_uuid))) { LASSERT(exp->exp_obd == obd); @@ -322,6 +326,12 @@ static int mds_connect(struct lustre_handle *conn, struct obd_device *obd, /* XXX There is a small race between checking the list and adding a * new connection for the same UUID, but the real threat (list * corruption when multiple different clients connect) is solved. + * + * There is a second race between adding the export to the list, + * and filling in the client data below. Hence skipping the case + * of NULL mcd above. We should already be controlling multiple + * connects at the client, and we can't hold the spinlock over + * memory allocations without risk of deadlocking. */ rc = class_connect(conn, obd, cluuid); if (rc) @@ -344,11 +354,11 @@ static int mds_connect(struct lustre_handle *conn, struct obd_device *obd, rc = mds_client_add(med, -1); if (rc) - GOTO(out_mdc, rc); + GOTO(out_mcd, rc); RETURN(0); -out_mdc: +out_mcd: OBD_FREE(mcd, sizeof(*mcd)); out_export: class_disconnect(conn); -- 1.8.3.1