r=adilger
- few clients connecting simultaneously might race in mds_lmv_connect().
just take a sem around code that connects to LMV
struct obd_device *mds_lmv_obd; /* XXX lmv_obd */
struct obd_export *mds_lmv_exp; /* XXX lov_exp */
struct ptlrpc_service *mds_create_service;
struct obd_device *mds_lmv_obd; /* XXX lmv_obd */
struct obd_export *mds_lmv_exp; /* XXX lov_exp */
struct ptlrpc_service *mds_create_service;
+ struct semaphore mds_lmv_sem;
atomic_t mds_real_clients;
struct obd_uuid mds_lmv_uuid;
struct dentry *mds_fids_dir;
atomic_t mds_real_clients;
struct obd_uuid mds_lmv_uuid;
struct dentry *mds_fids_dir;
lcfg->lcfg_inlbuf4);
/* we have to know mdsnum before touching underlying fs -bzzz */
lcfg->lcfg_inlbuf4);
/* we have to know mdsnum before touching underlying fs -bzzz */
+ sema_init(&mds->mds_lmv_sem, 1);
if (lcfg->lcfg_inllen5 > 0 && lcfg->lcfg_inlbuf5 &&
strcmp(lcfg->lcfg_inlbuf5, "dumb")) {
class_uuid_t uuid;
if (lcfg->lcfg_inllen5 > 0 && lcfg->lcfg_inlbuf5 &&
strcmp(lcfg->lcfg_inlbuf5, "dumb")) {
class_uuid_t uuid;
if (mds->mds_lmv_obd)
RETURN(0);
if (mds->mds_lmv_obd)
RETURN(0);
+ down(&mds->mds_lmv_sem);
+ if (mds->mds_lmv_obd) {
+ up(&mds->mds_lmv_sem);
+ RETURN(0);
+ }
+
mds->mds_lmv_obd = class_name2obd(lmv_name);
if (!mds->mds_lmv_obd) {
CERROR("MDS cannot locate LMV %s\n",
lmv_name);
mds->mds_lmv_obd = ERR_PTR(-ENOTCONN);
mds->mds_lmv_obd = class_name2obd(lmv_name);
if (!mds->mds_lmv_obd) {
CERROR("MDS cannot locate LMV %s\n",
lmv_name);
mds->mds_lmv_obd = ERR_PTR(-ENOTCONN);
+ GOTO(err_last, rc = -ENOTCONN);
}
rc = obd_connect(&conn, mds->mds_lmv_obd, &obd->obd_uuid, OBD_OPT_MDS_CONNECTION);
}
rc = obd_connect(&conn, mds->mds_lmv_obd, &obd->obd_uuid, OBD_OPT_MDS_CONNECTION);
CERROR("MDS cannot connect to LMV %s (%d)\n",
lmv_name, rc);
mds->mds_lmv_obd = ERR_PTR(rc);
CERROR("MDS cannot connect to LMV %s (%d)\n",
lmv_name, rc);
mds->mds_lmv_obd = ERR_PTR(rc);
}
mds->mds_lmv_exp = class_conn2export(&conn);
if (mds->mds_lmv_exp == NULL)
}
mds->mds_lmv_exp = class_conn2export(&conn);
if (mds->mds_lmv_exp == NULL)
if (rc)
GOTO(err_reg, rc);
if (rc)
GOTO(err_reg, rc);
obd_disconnect(mds->mds_lmv_exp, 0);
mds->mds_lmv_exp = NULL;
mds->mds_lmv_obd = ERR_PTR(rc);
obd_disconnect(mds->mds_lmv_exp, 0);
mds->mds_lmv_exp = NULL;
mds->mds_lmv_obd = ERR_PTR(rc);
+err_last:
+ up(&mds->mds_lmv_sem);
+ down(&mds->mds_lmv_sem);
if (!IS_ERR(mds->mds_lmv_obd) && mds->mds_lmv_exp != NULL) {
obd_register_observer(mds->mds_lmv_obd, NULL);
if (!IS_ERR(mds->mds_lmv_obd) && mds->mds_lmv_exp != NULL) {
obd_register_observer(mds->mds_lmv_obd, NULL);
mds->mds_lmv_exp = NULL;
mds->mds_lmv_obd = NULL;
}
mds->mds_lmv_exp = NULL;
mds->mds_lmv_obd = NULL;
}