#include <lustre_kernelcomm.h>
#include "lmv_internal.h"
+static int lmv_check_connect(struct obd_device *obd);
+
static void lmv_activate_target(struct lmv_obd *lmv,
struct lmv_tgt_desc *tgt,
int activate)
RETURN(rc);
}
-/**
- * This is fake connect function. Its purpose is to initialize lmv and say
- * caller that everything is okay. Real connection will be performed later.
- */
static int lmv_connect(const struct lu_env *env,
- struct obd_export **exp, struct obd_device *obd,
- struct obd_uuid *cluuid, struct obd_connect_data *data,
- void *localdata)
+ struct obd_export **pexp, struct obd_device *obd,
+ struct obd_uuid *cluuid, struct obd_connect_data *data,
+ void *localdata)
{
- struct lmv_obd *lmv = &obd->u.lmv;
- struct lustre_handle conn = { 0 };
- int rc = 0;
- ENTRY;
-
- /*
- * We don't want to actually do the underlying connections more than
- * once, so keep track.
- */
- lmv->refcount++;
- if (lmv->refcount > 1) {
- *exp = NULL;
- RETURN(0);
- }
-
- rc = class_connect(&conn, obd, cluuid);
- if (rc) {
- CERROR("class_connection() returned %d\n", rc);
- RETURN(rc);
- }
+ struct lmv_obd *lmv = &obd->u.lmv;
+ struct lustre_handle conn = { 0 };
+ struct obd_export *exp;
+ int rc;
+ ENTRY;
- *exp = class_conn2export(&conn);
- class_export_get(*exp);
+ rc = class_connect(&conn, obd, cluuid);
+ if (rc) {
+ CERROR("class_connection() returned %d\n", rc);
+ RETURN(rc);
+ }
- lmv->exp = *exp;
- lmv->connected = 0;
- lmv->cluuid = *cluuid;
+ exp = class_conn2export(&conn);
- if (data)
- lmv->conn_data = *data;
+ lmv->connected = 0;
+ lmv->cluuid = *cluuid;
+ lmv->conn_data = *data;
if (lmv->targets_proc_entry == NULL) {
lmv->targets_proc_entry = lprocfs_register("target_obds",
}
}
- /*
- * All real clients should perform actual connection right away, because
- * it is possible, that LMV will not have opportunity to connect targets
- * and MDC stuff will be called directly, for instance while reading
- * ../mdc/../kbytesfree procfs file, etc.
- */
- if (data != NULL && (data->ocd_connect_flags & OBD_CONNECT_REAL))
- rc = lmv_check_connect(obd);
+ rc = lmv_check_connect(obd);
+ if (rc != 0)
+ GOTO(out_proc, rc);
+
+ *pexp = exp;
- if (rc && lmv->targets_proc_entry != NULL)
- lprocfs_remove(&lmv->targets_proc_entry);
RETURN(rc);
+
+out_proc:
+ if (lmv->targets_proc_entry != NULL)
+ lprocfs_remove(&lmv->targets_proc_entry);
+
+ class_disconnect(exp);
+
+ return rc;
}
static int lmv_init_ea_size(struct obd_export *exp, __u32 easize,
RETURN(rc);
}
-int lmv_check_connect(struct obd_device *obd)
+static int lmv_check_connect(struct obd_device *obd)
{
struct lmv_obd *lmv = &obd->u.lmv;
struct lmv_tgt_desc *tgt;
GOTO(out_disc, rc);
}
- class_export_put(lmv->exp);
lmv->connected = 1;
easize = lmv_mds_md_size(lmv->desc.ld_tgt_count, LMV_MAGIC);
lmv_init_ea_size(obd->obd_self_export, easize, 0);
}
}
}
- class_disconnect(lmv->exp);
+
mutex_unlock(&lmv->lmv_init_mutex);
- RETURN(rc);
+
+ RETURN(rc);
}
static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
if (!lmv->tgts)
goto out_local;
- /*
- * Only disconnect the underlying layers on the final disconnect.
- */
- lmv->refcount--;
- if (lmv->refcount != 0)
- goto out_local;
-
for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL)
continue;
if (!lmv->connected)
class_export_put(exp);
rc = class_disconnect(exp);
- if (lmv->refcount == 0)
- lmv->connected = 0;
- RETURN(rc);
+ lmv->connected = 0;
+
+ RETURN(rc);
}
static int lmv_fid2path(struct obd_export *exp, int len, void *karg,
/* permanent error */
CERROR("%s: iocontrol MDC %s on MDT"
" idx %d cmd %x: err = %d\n",
- class_exp2obd(lmv->exp)->obd_name,
+ lmv2obd_dev(lmv)->obd_name,
tgt->ltd_uuid.uuid, i, cmd, err);
rc = err;
lk->lk_flags |= LK_FLG_STOP;
__u32 i;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
OBD_ALLOC(temp, sizeof(*temp));
if (temp == NULL)
RETURN(-ENOMEM);
int rc;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
rc = md_get_root(lmv->tgts[0]->ltd_exp, fileset, fid);
RETURN(rc);
}
int rc;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
tgt = lmv_find_target(lmv, fid);
if (IS_ERR(tgt))
RETURN(PTR_ERR(tgt));
int rc;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
tgt = lmv_find_target(lmv, fid);
if (IS_ERR(tgt))
RETURN(PTR_ERR(tgt));
int rc;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
tgt = lmv_find_target(lmv, &op_data->op_fid1);
if (IS_ERR(tgt))
RETURN(PTR_ERR(tgt));
struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv;
__u32 i;
- int rc;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
CDEBUG(D_INODE, "CBDATA for "DFID"\n", PFID(fid));
/*
int rc;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
tgt = lmv_find_target(lmv, &op_data->op_fid1);
if (IS_ERR(tgt))
RETURN(PTR_ERR(tgt));
int rc;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
if (!lmv->desc.ld_active_tgt_count)
RETURN(-EIO);
int rc;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID"\n",
LL_IT2STR(it), PFID(&op_data->op_fid1));
int rc;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
if (IS_ERR(tgt))
RETURN(PTR_ERR(tgt));
int rc;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
LASSERT(op_data->op_namelen != 0);
CDEBUG(D_INODE, "LINK "DFID":%*s to "DFID"\n",
(int)newlen, new, PFID(&op_data->op_fid2),
op_data->op_mea2 ? op_data->op_mea2->lsm_md_stripe_count : 0);
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
op_data->op_cap = cfs_curproc_cap_pack();
int rc = 0;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
CDEBUG(D_INODE, "SETATTR for "DFID", valid 0x%x\n",
PFID(&op_data->op_fid1), op_data->op_attr.ia_valid);
int rc;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc != 0)
- RETURN(rc);
-
tgt = lmv_find_target(lmv, fid);
if (IS_ERR(tgt))
RETURN(PTR_ERR(tgt));
struct md_callback *cb_op,
__u64 offset, struct page **ppage)
{
- struct obd_device *obd = exp->exp_obd;
struct lu_fid master_fid = op_data->op_fid1;
struct inode *master_inode = op_data->op_data;
__u64 hash_offset = offset;
int rc;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
/* Allocate a page and read entries from all of stripes and fill
* the page by hash order */
ent_page = alloc_page(GFP_KERNEL);
int rc;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc != 0)
- RETURN(rc);
-
if (unlikely(lsm != NULL)) {
rc = lmv_read_striped_page(exp, op_data, cb_op, offset, ppage);
RETURN(rc);
struct lmv_stripe_md *lsm = op_data->op_mea1;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
retry_unlink:
/* For striped dir, we need to locate the parent as well */
if (lsm != NULL) {
if (keylen >= strlen("remote_flag") && !strcmp(key, "remote_flag")) {
int i;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
LASSERT(*vallen == sizeof(__u32));
for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
struct lmv_tgt_desc *tgt = lmv->tgts[i];
} else if (KEY_IS(KEY_MAX_EASIZE) ||
KEY_IS(KEY_DEFAULT_EASIZE) ||
KEY_IS(KEY_CONN_DATA)) {
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
/*
* Forwarding this request to first MDS, it should know LOV
* desc.
if (!fid_is_sane(&op_data->op_fid2))
RETURN(-EINVAL);
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
ptgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
if (IS_ERR(ptgt))
RETURN(PTR_ERR(ptgt));
int rc;
ENTRY;
- rc = lmv_check_connect(obd);
- if (rc)
- RETURN(rc);
-
tgt = lmv_find_target(lmv, fid);
if (IS_ERR(tgt))
RETURN(PTR_ERR(tgt));