}
/* master lov connects to master ost here */
- rc = obd_connect(&conn, cmobd->cm_master_obd, &obd->obd_uuid);
+ rc = obd_connect(&conn, cmobd->cm_master_obd, &obd->obd_uuid, 0);
if (rc)
RETURN(rc);
cmobd->cm_master_exp = class_conn2export(&conn);
obd->obd_name, name);
RETURN(-EINVAL);
}
- rc = obd_connect(conn, obd, &obd_uuid);
+ rc = obd_connect(conn, obd, &obd_uuid, 0);
RETURN(rc);
}
static int
cobd_connect(struct lustre_handle *conn, struct obd_device *obd,
- struct obd_uuid *cluuid)
+ struct obd_uuid *cluuid, unsigned long connect_flags)
{
int rc;
rc = class_connect(conn, obd, cluuid);
imp_initial_recov:1, imp_force_verify:1,
imp_pingable:1, imp_resend_replay:1;
__u32 imp_connect_op;
+ __u32 imp_connect_flags;
};
typedef void (*obd_import_callback)(struct obd_import *imp, void *closure,
int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf);
int client_obd_cleanup(struct obd_device * obddev, int flags);
int client_connect_import(struct lustre_handle *conn, struct obd_device *obd,
- struct obd_uuid *cluuid);
+ struct obd_uuid *cluuid, unsigned long);
int client_disconnect_export(struct obd_export *exp, int failover);
/* ptlrpc/pinger.c */
int max_easize;
int max_cookiesize;
int server_timeout;
+ int connect_flags;
};
struct niobuf_local {
#define OBD_OPT_FORCE 0x0001
#define OBD_OPT_FAILOVER 0x0002
#define OBD_OPT_REAL_CLIENT 0x0004
+#define OBD_OPT_MDS_CONNECTION 0x0008
#define OBD_LLOG_FL_SENDNOW 0x0001
#define OBD_LLOG_FL_CREATE 0x0002
void *data);
int (*o_postrecov)(struct obd_device *dev);
int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
- struct obd_uuid *cluuid);
+ struct obd_uuid *cluuid, unsigned long connect_flags);
int (*o_disconnect)(struct obd_export *exp, int flags);
int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
}
static inline int obd_connect(struct lustre_handle *conn,
- struct obd_device *obd, struct obd_uuid *cluuid)
+ struct obd_device *obd, struct obd_uuid *cluuid,
+ unsigned long connect_flags)
{
int rc;
ENTRY;
OBD_CHECK_OP(obd, connect, -EOPNOTSUPP);
OBD_COUNTER_INCREMENT(obd, connect);
- rc = OBP(obd, connect)(conn, obd, cluuid);
+ rc = OBP(obd, connect)(conn, obd, cluuid, connect_flags);
RETURN(rc);
}
int client_connect_import(struct lustre_handle *dlm_handle,
struct obd_device *obd,
- struct obd_uuid *cluuid)
+ struct obd_uuid *cluuid,
+ unsigned long connect_flags)
{
struct client_obd *cli = &obd->u.cli;
struct obd_import *imp = cli->cl_import;
GOTO(out_ldlm, rc);
exp->exp_connection = ptlrpc_connection_addref(imp->imp_connection);
+ imp->imp_connect_flags = connect_flags;
rc = ptlrpc_connect_import(imp, NULL);
if (rc != 0) {
LASSERT (imp->imp_state == LUSTRE_IMP_DISCON);
int target_handle_connect(struct ptlrpc_request *req)
{
+ unsigned long connect_flags = 0, *cfp;
struct obd_device *target;
struct obd_export *export = NULL;
struct obd_import *revimp;
memcpy(&conn, tmp, sizeof conn);
+ cfp = lustre_msg_buf(req->rq_reqmsg, 3, sizeof(unsigned long));
+ LASSERT(cfp != NULL);
+ connect_flags = *cfp;
+
rc = lustre_pack_reply(req, 0, NULL, NULL);
if (rc)
GOTO(out, rc);
/* Tell the client if we're in recovery. */
/* If this is the first client, start the recovery timer */
- CWARN("%s: connection from %s@%s %s\n", target->obd_name, cluuid.uuid,
- ptlrpc_peernid2str(&req->rq_peer, peer_str),
+ CWARN("%s: connection from %s@%s/%lu %s\n", target->obd_name, cluuid.uuid,
+ ptlrpc_peernid2str(&req->rq_peer, peer_str), *cfp,
target->obd_recovering ? "(recovering)" : "");
if (target->obd_recovering) {
lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_RECOVERING);
rc = -EBUSY;
} else {
dont_check_exports:
- rc = obd_connect(&conn, target, &cluuid);
+ rc = obd_connect(&conn, target, &cluuid, connect_flags);
}
}
/* Tell the client if we support replayable requests */
valsize = sizeof(desc);
rc = obd_get_info(sbi->ll_osc_exp, strlen("lovdesc") + 1, "lovdesc",
&valsize, &desc);
- if (rc == 0) {
- obd_init_ea_size(sbi->ll_mdc_exp,
- obd_size_diskmd(sbi->ll_osc_exp, NULL),
- desc.ld_tgt_count*sizeof(struct llog_cookie));
-
- /* declare ourself as real client. not connection
- * from another MDS
- * FIXME: remove fake valsize, mdsize --bzzz */
- rc = obd_set_info(sbi->ll_mdc_exp, strlen("client"),
- "client", valsize, &desc);
- }
+ if (rc)
+ RETURN(rc);
+ obd_init_ea_size(sbi->ll_mdc_exp, obd_size_diskmd(sbi->ll_osc_exp, NULL),
+ desc.ld_tgt_count*sizeof(struct llog_cookie));
+
RETURN(rc);
}
#if CONFIG_SNAPFS
CERROR("could not register mount in /proc/lustre");
}
- err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid);
+ err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid, 0);
if (err == -EBUSY) {
CERROR("An MDS (mdc %s) is performing recovery, of which this"
" client is not a part. Please wait for recovery to "
GOTO(out_mdc, err);
}
- err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid);
+ err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid, 0);
if (err == -EBUSY) {
CERROR("An OST (osc %s) is performing recovery, of which this"
" client is not a part. Please wait for recovery to "
if (err)
GOTO(out_cleanup, err);
- err = obd_connect(&mdc_conn, obd, &mdc_uuid);
+ err = obd_connect(&mdc_conn, obd, &mdc_uuid, 0);
if (err) {
CERROR("cannot connect to %s: rc = %d\n", lmd->lmd_mds, err);
GOTO(out_cleanup, err);
* say caller that everything is okay. Real connection will be performed
* later. */
static int lmv_connect(struct lustre_handle *conn, struct obd_device *obd,
- struct obd_uuid *cluuid)
+ struct obd_uuid *cluuid, unsigned long connect_flags)
{
struct lmv_obd *lmv = &obd->u.lmv;
struct obd_export *exp;
}
lmv->cluuid = *cluuid;
+ lmv->connect_flags = connect_flags;
lmv->connected = 0;
lmv->exp = exp;
}
/* Performs a check if passed obd is connected. If no - connect it. */
-int lmv_check_connect(struct obd_device *obd) {
+int lmv_check_connect(struct obd_device *obd)
+{
struct lmv_obd *lmv = &obd->u.lmv;
struct obd_uuid *cluuid;
struct lmv_tgt_desc *tgts;
GOTO(out_disc, rc = -EINVAL);
}
- rc = obd_connect(&conn, tgt_obd, &lmv_osc_uuid);
+ rc = obd_connect(&conn, tgt_obd, &lmv_osc_uuid, lmv->connect_flags);
if (rc) {
CERROR("Target %s connect error %d\n",
tgts->uuid.uuid, rc);
}
lmv = &obd->u.lmv;
- if (keylen >= strlen("client") && strcmp(key, "client") == 0) {
- struct lmv_tgt_desc *tgts;
- int i, rc;
-
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
- for (i = 0, tgts = lmv->tgts;
- i < lmv->desc.ld_tgt_count; i++, tgts++) {
- rc = obd_set_info(tgts->ltd_exp, keylen, key, vallen, val);
- if (rc)
- RETURN(rc);
- }
- RETURN(0);
- } else if (keylen >= strlen("inter_mds") && strcmp(key, "inter_mds") == 0) {
+ if (keylen >= strlen("inter_mds") && strcmp(key, "inter_mds") == 0) {
lmv->server_timeout = 1;
lmv_set_timeouts(obd);
RETURN(0);
RETURN(0);
}
- rc = obd_connect(&conn, tgt_obd, &lov_osc_uuid);
+ rc = obd_connect(&conn, tgt_obd, &lov_osc_uuid, 0);
if (rc) {
CERROR("Target %s connect error %d\n", tgt_uuid->uuid, rc);
RETURN(rc);
}
static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
- struct obd_uuid *cluuid)
+ struct obd_uuid *cluuid, unsigned long connect_flags)
{
struct lov_obd *lov = &obd->u.lov;
struct lov_tgt_desc *tgt;
exp->exp_obd->obd_name,
imp->imp_initial_recov);
RETURN(0);
- } else if (keylen >= strlen("client") && strcmp(key, "client") == 0) {
- struct ptlrpc_request *req;
- char *bufs[1] = {key};
- int rc;
- req = ptlrpc_prep_req(class_exp2cliimp(exp), OST_SET_INFO, 1,
- &keylen, bufs);
- if (req == NULL)
- RETURN(-ENOMEM);
-
- req->rq_replen = lustre_msg_size(0, NULL);
- rc = ptlrpc_queue_wait(req);
- ptlrpc_req_finished(req);
- RETURN(rc);
} else if (keylen >= strlen("mds_num") && strcmp(key, "mds_num") == 0) {
struct ptlrpc_request *req;
int rc, size[2] = {keylen, vallen};
* on the server, etc.
*/
static int mds_connect(struct lustre_handle *conn, struct obd_device *obd,
- struct obd_uuid *cluuid)
+ struct obd_uuid *cluuid, unsigned long connect_flags)
{
struct obd_export *exp;
struct mds_export_data *med; /* */
med->med_mcd = mcd;
rc = mds_client_add(obd, &obd->u.mds, med, -1);
- if (rc == 0)
- EXIT;
+ if (rc)
+ GOTO(out, rc);
+
+ if (!(connect_flags & OBD_OPT_MDS_CONNECTION)) {
+ struct mds_obd *mds = &obd->u.mds;
+ if (!(exp->exp_flags & OBD_OPT_REAL_CLIENT)) {
+ atomic_inc(&mds->mds_real_clients);
+ CDEBUG(D_OTHER,"%s: peer from %s is real client (%d)\n",
+ obd->obd_name, exp->exp_client_uuid.uuid,
+ atomic_read(&mds->mds_real_clients));
+ exp->exp_flags |= OBD_OPT_REAL_CLIENT;
+ }
+ if (mds->mds_lmv_name)
+ rc = mds_lmv_connect(obd, mds->mds_lmv_name);
+ }
+ EXIT;
out:
if (rc) {
OBD_FREE(mcd, sizeof(*mcd));
rc = obd_set_info(mds->mds_osc_exp, strlen("mds_conn"), "mds_conn",
valsize, &group);
RETURN(rc);
- } else if (KEY_IS("client")) {
- if (!(exp->exp_flags & OBD_OPT_REAL_CLIENT)) {
- atomic_inc(&mds->mds_real_clients);
- CDEBUG(D_OTHER,"%s: peer from %s is real client (%d)\n",
- obd->obd_name, exp->exp_client_uuid.uuid,
- atomic_read(&mds->mds_real_clients));
- exp->exp_flags |= OBD_OPT_REAL_CLIENT;
- }
- if (mds->mds_lmv_name) {
- rc = mds_lmv_connect(obd, mds->mds_lmv_name);
- LASSERT(rc == 0);
- }
- RETURN(0);
}
CDEBUG(D_IOCTL, "invalid key\n");
RETURN(-EINVAL);
RETURN(-ENOTCONN);
}
- rc = obd_connect(&conn, mds->mds_lmv_obd, &obd->obd_uuid);
+ rc = obd_connect(&conn, mds->mds_lmv_obd, &obd->obd_uuid, OBD_OPT_MDS_CONNECTION);
if (rc) {
CERROR("MDS cannot connect to LMV %s (%d)\n",
lmv_name, rc);
"inter_mds", 0, NULL);
if (rc)
GOTO(err_reg, rc);
-
+
RETURN(0);
err_reg:
CDEBUG(D_HA, "obd: %s osc: %s lov_name: %s\n",
obd->obd_name, mds->mds_osc_obd->obd_name, lov_name);
- rc = obd_connect(&conn, mds->mds_osc_obd, &obd->obd_uuid);
+ rc = obd_connect(&conn, mds->mds_osc_obd, &obd->obd_uuid, 0);
if (rc) {
CERROR("MDS cannot connect to LOV %s (%d)\n",
lov_name, rc);
RETURN(-ENOENT);
}
- rc = obd_connect(&exph, mdc_obd, &uuid);
+ rc = obd_connect(&exph, mdc_obd, &uuid, 0);
if (rc) {
CERROR("6: failed to connect to MDC: %s\n", mdc_obd->obd_name);
RETURN(rc);
};
static int echo_connect(struct lustre_handle *conn, struct obd_device *obd,
- struct obd_uuid *cluuid)
+ struct obd_uuid *cluuid, unsigned long connect_flags)
{
return class_connect(conn, obd, cluuid);
}
INIT_LIST_HEAD (&ec->ec_objects);
ec->ec_unique = 0;
- rc = obd_connect(&conn, tgt, &echo_uuid);
+ rc = obd_connect(&conn, tgt, &echo_uuid, 0);
if (rc) {
CERROR("fail to connect to device %s\n", lcfg->lcfg_inlbuf1);
return (rc);
}
static int echo_client_connect(struct lustre_handle *conn,
- struct obd_device *src, struct obd_uuid *cluuid)
+ struct obd_device *src, struct obd_uuid *cluuid,
+ unsigned long connect_flags)
{
struct obd_export *exp;
int rc;
/* nearly identical to mds_connect */
static int filter_connect(struct lustre_handle *conn, struct obd_device *obd,
- struct obd_uuid *cluuid)
+ struct obd_uuid *cluuid, unsigned long connect_flags)
{
struct obd_export *exp;
struct filter_export_data *fed;
static int osc_connect(struct lustre_handle *exph,
- struct obd_device *obd, struct obd_uuid *cluuid)
+ struct obd_device *obd, struct obd_uuid *cluuid,
+ unsigned long connect_flags)
{
int rc;
- rc = client_connect_import(exph, obd, cluuid);
+ rc = client_connect_import(exph, obd, cluuid, 0);
return rc;
}
/* modelled after ptlrpc_import_connect() */
int ptlbd_cl_connect(struct lustre_handle *conn, struct obd_device *obd,
- struct obd_uuid *target_uuid)
+ struct obd_uuid *target_uuid, unsigned long connect_flags)
{
struct ptlbd_obd *ptlbd = &obd->u.ptlbd;
struct obd_import *imp = ptlbd->bd_import;
ENTRY;
memset(&conn, 0, sizeof(conn));
- rc = obd_connect(&conn, obd, &ptlbd->bd_server_uuid);
+ rc = obd_connect(&conn, obd, &ptlbd->bd_server_uuid, 0);
if (rc < 0)
RETURN(rc);
ptlbd->bd_exp = class_conn2export(&conn);
RETURN(0);
}
+static int ptlbd_connect(struct lustre_handle *conn, struct obd_device *obd,
+ struct obd_uuid *cluuid, unsigned long connect_flags)
+{
+ int rc;
+
+ rc = class_connect(conn, obd, cluuid);
+ RETURN(rc);
+}
+
static struct obd_ops ptlbd_sv_obd_ops = {
.o_owner = THIS_MODULE,
.o_attach = ptlbd_sv_attach,
.o_detach = ptlbd_sv_detach,
.o_setup = ptlbd_sv_setup,
.o_cleanup = ptlbd_sv_cleanup,
- .o_connect = class_connect,
+ .o_connect = ptlbd_connect,
.o_disconnect = class_disconnect,
};
struct ptlrpc_request *request;
int size[] = {sizeof(imp->imp_target_uuid),
sizeof(obd->obd_uuid),
- sizeof(imp->imp_dlm_handle)};
+ sizeof(imp->imp_dlm_handle),
+ sizeof(unsigned long)};
char *tmp[] = {imp->imp_target_uuid.uuid,
obd->obd_uuid.uuid,
- (char *)&imp->imp_dlm_handle};
+ (char *)&imp->imp_dlm_handle,
+ (char *)&imp->imp_connect_flags}; /* XXX: make this portable! */
struct ptlrpc_connect_async_args *aa;
unsigned long flags;
}
- request = ptlrpc_prep_req(imp, imp->imp_connect_op, 3, size, tmp);
+ request = ptlrpc_prep_req(imp, imp->imp_connect_op, 4, size, tmp);
if (!request)
GOTO(out, rc = -ENOMEM);