#include <lustre_param.h>
#include <lustre_quota.h>
#include <lustre_lfsck.h>
+#include <lustre_nodemap.h>
mdl_mode_t mdt_mdl_lock_modes[] = {
[LCK_MINMODE] = MDL_MINMODE,
b->mbo_blocks = ma->ma_som->msd_blocks;
}
+#ifdef CONFIG_FS_POSIX_ACL
+/*
+ * Pack ACL data into the reply. UIDs/GIDs are mapped and filtered by nodemap.
+ *
+ * \param info thread info object
+ * \param repbody reply to pack ACLs into
+ * \param o mdt object of file to examine
+ * \param nodemap nodemap of client to reply to
+ * \retval 0 success
+ * \retval -errno error getting or parsing ACL from disk
+ */
+int mdt_pack_acl2body(struct mdt_thread_info *info, struct mdt_body *repbody,
+ struct mdt_object *o, struct lu_nodemap *nodemap)
+{
+ const struct lu_env *env = info->mti_env;
+ struct md_object *next = mdt_object_child(o);
+ struct lu_buf *buf = &info->mti_buf;
+ int rc;
+
+ buf->lb_buf = req_capsule_server_get(info->mti_pill, &RMF_ACL);
+ buf->lb_len = req_capsule_get_size(info->mti_pill, &RMF_ACL,
+ RCL_SERVER);
+ if (buf->lb_len == 0)
+ return 0;
+
+ rc = mo_xattr_get(env, next, buf, XATTR_NAME_ACL_ACCESS);
+ if (rc < 0) {
+ if (rc == -ENODATA) {
+ repbody->mbo_aclsize = 0;
+ repbody->mbo_valid |= OBD_MD_FLACL;
+ rc = 0;
+ } else if (rc == -EOPNOTSUPP) {
+ rc = 0;
+ } else {
+ CERROR("%s: unable to read "DFID" ACL: rc = %d\n",
+ mdt_obd_name(info->mti_mdt),
+ PFID(mdt_object_fid(o)), rc);
+ }
+ } else {
+ rc = nodemap_map_acl(nodemap, buf->lb_buf,
+ rc, NODEMAP_FS_TO_CLIENT);
+ /* if all ACLs mapped out, rc is still >= 0 */
+ if (rc < 0) {
+ CERROR("%s: nodemap_map_acl unable to parse "DFID
+ " ACL: rc = %d\n", mdt_obd_name(info->mti_mdt),
+ PFID(mdt_object_fid(o)), rc);
+ } else {
+ repbody->mbo_aclsize = rc;
+ repbody->mbo_valid |= OBD_MD_FLACL;
+ rc = 0;
+ }
+ }
+ return rc;
+}
+#endif
+
void mdt_pack_attr2body(struct mdt_thread_info *info, struct mdt_body *b,
const struct lu_attr *attr, const struct lu_fid *fid)
{
- struct md_attr *ma = &info->mti_attr;
+ struct md_attr *ma = &info->mti_attr;
+ struct obd_export *exp = info->mti_exp;
+ struct lu_nodemap *nodemap = exp->exp_target_data.ted_nodemap;
- LASSERT(ma->ma_valid & MA_INODE);
+ LASSERT(ma->ma_valid & MA_INODE);
b->mbo_atime = attr->la_atime;
b->mbo_mtime = attr->la_mtime;
b->mbo_mode = attr->la_mode;
b->mbo_size = attr->la_size;
b->mbo_blocks = attr->la_blocks;
- b->mbo_uid = attr->la_uid;
- b->mbo_gid = attr->la_gid;
+ b->mbo_uid = nodemap_map_id(nodemap, NODEMAP_UID,
+ NODEMAP_FS_TO_CLIENT,
+ attr->la_uid);
+ b->mbo_gid = nodemap_map_id(nodemap, NODEMAP_GID,
+ NODEMAP_FS_TO_CLIENT,
+ attr->la_gid);
b->mbo_flags = attr->la_flags;
b->mbo_nlink = attr->la_nlink;
b->mbo_rdev = attr->la_rdev;
static int mdt_getattr_internal(struct mdt_thread_info *info,
struct mdt_object *o, int ma_need)
{
- struct md_object *next = mdt_object_child(o);
- const struct mdt_body *reqbody = info->mti_body;
- struct ptlrpc_request *req = mdt_info_req(info);
- struct md_attr *ma = &info->mti_attr;
- struct lu_attr *la = &ma->ma_attr;
- struct req_capsule *pill = info->mti_pill;
- const struct lu_env *env = info->mti_env;
- struct mdt_body *repbody;
- struct lu_buf *buffer = &info->mti_buf;
- int rc;
- int is_root;
- ENTRY;
+ struct md_object *next = mdt_object_child(o);
+ const struct mdt_body *reqbody = info->mti_body;
+ struct ptlrpc_request *req = mdt_info_req(info);
+ struct md_attr *ma = &info->mti_attr;
+ struct lu_attr *la = &ma->ma_attr;
+ struct req_capsule *pill = info->mti_pill;
+ const struct lu_env *env = info->mti_env;
+ struct mdt_body *repbody;
+ struct lu_buf *buffer = &info->mti_buf;
+ struct obd_export *exp = info->mti_exp;
+ struct lu_nodemap *nodemap = exp->exp_target_data.ted_nodemap;
+ int rc;
+ int is_root;
+ ENTRY;
- if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETATTR_PACK))
- RETURN(err_serious(-ENOMEM));
+ if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETATTR_PACK))
+ RETURN(err_serious(-ENOMEM));
- repbody = req_capsule_server_get(pill, &RMF_MDT_BODY);
+ repbody = req_capsule_server_get(pill, &RMF_MDT_BODY);
- ma->ma_valid = 0;
+ ma->ma_valid = 0;
if (mdt_object_remote(o)) {
/* This object is located on remote node.*/
}
#ifdef CONFIG_FS_POSIX_ACL
else if ((exp_connect_flags(req->rq_export) & OBD_CONNECT_ACL) &&
- (reqbody->mbo_valid & OBD_MD_FLACL)) {
- buffer->lb_buf = req_capsule_server_get(pill, &RMF_ACL);
- buffer->lb_len = req_capsule_get_size(pill,
- &RMF_ACL, RCL_SERVER);
- if (buffer->lb_len > 0) {
- rc = mo_xattr_get(env, next, buffer,
- XATTR_NAME_ACL_ACCESS);
- if (rc < 0) {
- if (rc == -ENODATA) {
- repbody->mbo_aclsize = 0;
- repbody->mbo_valid |= OBD_MD_FLACL;
- rc = 0;
- } else if (rc == -EOPNOTSUPP) {
- rc = 0;
- } else {
- CERROR("%s: unable to read "DFID
- " ACL: rc = %d\n",
- mdt_obd_name(info->mti_mdt),
- PFID(mdt_object_fid(o)), rc);
- }
- } else {
- repbody->mbo_aclsize = rc;
- repbody->mbo_valid |= OBD_MD_FLACL;
- rc = 0;
- }
- }
- }
+ (reqbody->mbo_valid & OBD_MD_FLACL))
+ rc = mdt_pack_acl2body(info, repbody, o, nodemap);
#endif
if (reqbody->mbo_valid & OBD_MD_FLMDSCAPA &&
}
if (rc < 0)
- GOTO(out_shrink, rc);
+ GOTO(out, rc = err_serious(rc));
req_capsule_set_size(pill, &RMF_MDT_MD, RCL_SERVER, rc);
info = tsi2mdt_info(tsi);
if (info->mti_dlm_req != NULL)
- ldlm_request_cancel(req, info->mti_dlm_req, 0);
+ ldlm_request_cancel(req, info->mti_dlm_req, 0, LATF_SKIP);
if (req_capsule_get_size(info->mti_pill, &RMF_CAPA1, RCL_CLIENT))
mdt_set_capainfo(info, 0, &info->mti_body->mbo_fid1,
}
static int mdt_raw_lookup(struct mdt_thread_info *info,
- struct mdt_object *parent,
- const struct lu_name *lname,
- struct ldlm_reply *ldlm_rep)
+ struct mdt_object *parent,
+ const struct lu_name *lname,
+ struct ldlm_reply *ldlm_rep)
{
- struct md_object *next = mdt_object_child(info->mti_object);
- const struct mdt_body *reqbody = info->mti_body;
- struct lu_fid *child_fid = &info->mti_tmp_fid1;
- struct mdt_body *repbody;
- int rc;
- ENTRY;
-
- if (reqbody->mbo_valid != OBD_MD_FLID)
- RETURN(0);
+ struct lu_fid *child_fid = &info->mti_tmp_fid1;
+ int rc;
+ ENTRY;
- LASSERT(!info->mti_cross_ref);
+ LASSERT(!info->mti_cross_ref);
- /* Only got the fid of this obj by name */
- fid_zero(child_fid);
- rc = mdo_lookup(info->mti_env, next, lname, child_fid,
- &info->mti_spec);
-#if 0
- /* XXX is raw_lookup possible as intent operation? */
- if (rc != 0) {
- if (rc == -ENOENT)
- mdt_set_disposition(info, ldlm_rep, DISP_LOOKUP_NEG);
- RETURN(rc);
- } else
- mdt_set_disposition(info, ldlm_rep, DISP_LOOKUP_POS);
+ /* Only got the fid of this obj by name */
+ fid_zero(child_fid);
+ rc = mdo_lookup(info->mti_env, mdt_object_child(info->mti_object),
+ lname, child_fid, &info->mti_spec);
+ if (rc == 0) {
+ struct mdt_body *repbody;
- repbody = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY);
-#endif
- if (rc == 0) {
- repbody = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY);
+ repbody = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY);
repbody->mbo_fid1 = *child_fid;
repbody->mbo_valid = OBD_MD_FLID;
- }
- RETURN(1);
+ mdt_set_disposition(info, ldlm_rep, DISP_LOOKUP_POS);
+ } else if (rc == -ENOENT) {
+ mdt_set_disposition(info, ldlm_rep, DISP_LOOKUP_NEG);
+ }
+
+ RETURN(rc);
}
/*
struct mdt_body *reqbody = NULL;
struct mdt_object *parent = info->mti_object;
struct mdt_object *child;
- struct md_object *next = mdt_object_child(parent);
struct lu_fid *child_fid = &info->mti_tmp_fid1;
struct lu_name *lname = NULL;
struct mdt_lock_handle *lhp = NULL;
LASSERT(ergo(is_resent,
lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT));
- LASSERT(parent != NULL);
+ if (parent == NULL)
+ RETURN(-ENOENT);
if (info->mti_cross_ref) {
/* Only getattr on the child. Parent is on another node. */
rc = mdt_check_resent_lock(info, child, lhc);
if (rc < 0) {
- RETURN(-EPROTO);
+ RETURN(rc);
} else if (rc > 0) {
mdt_lock_handle_init(lhc);
mdt_lock_reg_init(lhc, LCK_PR);
}
if (lu_name_is_valid(lname)) {
- rc = mdt_raw_lookup(info, parent, lname, ldlm_rep);
- if (rc != 0) {
- if (rc > 0)
- rc = 0;
+ /* Always allow to lookup ".." */
+ if (unlikely(lname->ln_namelen == 2 &&
+ lname->ln_name[0] == '.' &&
+ lname->ln_name[1] == '.'))
+ info->mti_spec.sp_permitted = 1;
+
+ if (info->mti_body->mbo_valid == OBD_MD_FLID) {
+ rc = mdt_raw_lookup(info, parent, lname, ldlm_rep);
+
RETURN(rc);
}
/* step 2: lookup child's fid by name */
fid_zero(child_fid);
- rc = mdo_lookup(info->mti_env, next, lname, child_fid,
- &info->mti_spec);
+ rc = mdo_lookup(info->mti_env, mdt_object_child(parent), lname,
+ child_fid, &info->mti_spec);
if (rc == -ENOENT)
mdt_set_disposition(info, ldlm_rep, DISP_LOOKUP_NEG);
int id, rc;
struct mdt_device *mdt = mdt_exp2dev(exp);
struct lu_device *qmt = mdt->mdt_qmt_dev;
+ struct lu_nodemap *nodemap = exp->exp_target_data.ted_nodemap;
ENTRY;
oqctl = req_capsule_client_get(pill, &RMF_OBD_QUOTACTL);
/* deprecated, not used any more */
RETURN(-EOPNOTSUPP);
/* master quotactl */
- case Q_GETINFO:
case Q_SETINFO:
case Q_SETQUOTA:
+ if (!nodemap_can_setquota(nodemap))
+ RETURN(-EPERM);
+ case Q_GETINFO:
case Q_GETQUOTA:
if (qmt == NULL)
RETURN(-EOPNOTSUPP);
}
}
+ if (oqctl->qc_type == USRQUOTA)
+ id = nodemap_map_id(nodemap, NODEMAP_UID,
+ NODEMAP_CLIENT_TO_FS, id);
+ else if (oqctl->qc_type == GRPQUOTA)
+ id = nodemap_map_id(nodemap, NODEMAP_UID,
+ NODEMAP_CLIENT_TO_FS, id);
+
repoqc = req_capsule_server_get(pill, &RMF_OBD_QUOTACTL);
if (repoqc == NULL)
RETURN(err_serious(-EFAULT));
lock = ldlm_handle2lock(&lhc->mlh_reg_lh);
LASSERT(lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT);
- LASSERTF(lock != NULL, "Invalid lock handle "LPX64"\n",
- lhc->mlh_reg_lh.cookie);
+ if (lock == NULL) {
+ /* Lock is pinned by ldlm_handle_enqueue0() as it is
+ * a resend case, however, it could be already destroyed
+ * due to client eviction or a raced cancel RPC. */
+ LDLM_DEBUG_NOLOCK("Invalid lock handle "LPX64"\n",
+ lhc->mlh_reg_lh.cookie);
+ RETURN(-ESTALE);
+ }
if (!fid_res_name_eq(mdt_object_fid(mo),
&lock->l_resource->lr_name)) {
info->mti_spec.no_create = 0;
info->mti_spec.sp_rm_entry = 0;
+ info->mti_spec.sp_permitted = 0;
info->mti_spec.u.sp_ea.eadata = NULL;
info->mti_spec.u.sp_ea.eadatalen = 0;
if (OBD_FAIL_CHECK(OBD_FAIL_TGT_DELAY_CONDITIONAL) &&
cfs_fail_val ==
tsi2mdt_info(tsi)->mti_mdt->mdt_seq_site.ss_node_id)
- schedule_timeout_and_set_state(TASK_UNINTERRUPTIBLE, HZ * 3);
+ schedule_timeout_and_set_state(TASK_UNINTERRUPTIBLE,
+ msecs_to_jiffies(3 * MSEC_PER_SEC));
rc = tgt_connect(tsi);
if (rc != 0)
static int mdt_intent_opc(long itopc, struct mdt_thread_info *info,
struct ldlm_lock **lockp, __u64 flags)
{
- struct req_capsule *pill;
- struct mdt_it_flavor *flv;
- int opc;
- int rc;
- ENTRY;
-
- opc = mdt_intent_code(itopc);
- if (opc < 0)
- RETURN(-EINVAL);
+ struct req_capsule *pill = info->mti_pill;
+ struct ptlrpc_request *req = mdt_info_req(info);
+ struct mdt_it_flavor *flv;
+ int opc;
+ int rc;
+ ENTRY;
- pill = info->mti_pill;
+ opc = mdt_intent_code(itopc);
+ if (opc < 0)
+ RETURN(-EINVAL);
if (opc == MDT_IT_QUOTA) {
struct lu_device *qmt = info->mti_mdt->mdt_qmt_dev;
RETURN(rc);
}
- flv = &mdt_it_flavor[opc];
- if (flv->it_fmt != NULL)
- req_capsule_extend(pill, flv->it_fmt);
+ flv = &mdt_it_flavor[opc];
+ if (flv->it_fmt != NULL)
+ req_capsule_extend(pill, flv->it_fmt);
- rc = mdt_unpack_req_pack_rep(info, flv->it_flags);
- if (rc == 0) {
- struct ptlrpc_request *req = mdt_info_req(info);
- if (flv->it_flags & MUTABOR &&
- exp_connect_flags(req->rq_export) & OBD_CONNECT_RDONLY)
- RETURN(-EROFS);
- }
- if (rc == 0 && flv->it_act != NULL) {
+ rc = mdt_unpack_req_pack_rep(info, flv->it_flags);
+ if (rc < 0)
+ RETURN(rc);
+
+ if (flv->it_flags & MUTABOR &&
+ exp_connect_flags(req->rq_export) & OBD_CONNECT_RDONLY)
+ RETURN(-EROFS);
+
+ if (flv->it_act != NULL) {
struct ldlm_reply *rep;
/* execute policy */
rc = flv->it_act(opc, info, lockp, flags);
/* Check whether the reply has been packed successfully. */
- if (mdt_info_req(info)->rq_repmsg != NULL) {
+ if (req->rq_repmsg != NULL) {
rep = req_capsule_server_get(info->mti_pill,
&RMF_DLM_REP);
rep->lock_policy_res2 =
ptlrpc_status_hton(rep->lock_policy_res2);
}
- } else {
- rc = -EPROTO;
}
+
RETURN(rc);
}
if (!obd) {
CERROR("Can not find obd %s (%s in config)\n",
MDD_OBD_NAME, lustre_cfg_string(cfg, 0));
- GOTO(class_detach, rc = -EINVAL);
+ GOTO(lcfg_cleanup, rc = -EINVAL);
}
lustre_cfg_free(lcfg);
if (!obd) {
CERROR("Can not find obd %s (%s in config)\n", qmtname,
lustre_cfg_string(cfg, 0));
- GOTO(class_detach, rc = -EINVAL);
+ GOTO(lcfg_cleanup, rc = -EINVAL);
}
lustre_cfg_free(lcfg);
}
}
- rc = class_process_proc_seq_param(PARAM_MDT, obd->obd_vars,
- cfg, obd);
+ rc = class_process_proc_param(PARAM_MDT, obd->obd_vars,
+ cfg, obd);
if (rc > 0 || rc == -ENOSYS) {
/* is it an HSM var ? */
- rc = class_process_proc_seq_param(PARAM_HSM,
- hsm_cdt_get_proc_vars(),
- cfg, obd);
+ rc = class_process_proc_param(PARAM_HSM,
+ hsm_cdt_get_proc_vars(),
+ cfg, obd);
if (rc > 0 || rc == -ENOSYS)
/* we don't understand; pass it on */
rc = next->ld_ops->ldo_process_config(env, next,
return 0;
}
-/* mds_connect copy */
-static int mdt_obd_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 *lexp;
- struct lustre_handle conn = { 0 };
- struct mdt_device *mdt;
- int rc;
- ENTRY;
-
- LASSERT(env != NULL);
- if (!exp || !obd || !cluuid)
- RETURN(-EINVAL);
-
- mdt = mdt_dev(obd->obd_lu_dev);
-
- /*
- * first, check whether the stack is ready to handle requests
- * XXX: probably not very appropriate method is used now
- * at some point we should find a better one
- */
- if (!test_bit(MDT_FL_SYNCED, &mdt->mdt_state) && data != NULL &&
- !(data->ocd_connect_flags & OBD_CONNECT_LIGHTWEIGHT)) {
- rc = obd_get_info(env, mdt->mdt_child_exp,
- sizeof(KEY_OSP_CONNECTED),
- KEY_OSP_CONNECTED, NULL, NULL, NULL);
- if (rc)
- RETURN(-EAGAIN);
- set_bit(MDT_FL_SYNCED, &mdt->mdt_state);
- }
-
- rc = class_connect(&conn, obd, cluuid);
- if (rc)
- RETURN(rc);
-
- lexp = class_conn2export(&conn);
- LASSERT(lexp != NULL);
-
- rc = mdt_connect_internal(lexp, mdt, data);
- if (rc == 0) {
- struct lsd_client_data *lcd = lexp->exp_target_data.ted_lcd;
-
- LASSERT(lcd);
- memcpy(lcd->lcd_uuid, cluuid, sizeof lcd->lcd_uuid);
- rc = tgt_client_new(env, lexp);
- if (rc == 0)
- mdt_export_stats_init(obd, lexp, localdata);
-
- /* For phase I, sync for cross-ref operation. */
- lexp->exp_keep_sync = 1;
- }
-
- if (rc != 0) {
- class_disconnect(lexp);
- *exp = NULL;
- } else {
- *exp = lexp;
- }
-
- RETURN(rc);
-}
-
-static int mdt_obd_reconnect(const struct lu_env *env,
- struct obd_export *exp, struct obd_device *obd,
- struct obd_uuid *cluuid,
- struct obd_connect_data *data,
- void *localdata)
-{
- int rc;
- ENTRY;
-
- if (exp == NULL || obd == NULL || cluuid == NULL)
- RETURN(-EINVAL);
-
- rc = mdt_connect_internal(exp, mdt_dev(obd->obd_lu_dev), data);
- if (rc == 0)
- mdt_export_stats_init(obd, exp, localdata);
-
- RETURN(rc);
-}
-
static int mdt_ctxt_add_dirty_flag(struct lu_env *env,
struct mdt_thread_info *info,
struct mdt_file_data *mfd)
static int mdt_export_cleanup(struct obd_export *exp)
{
- struct mdt_export_data *med = &exp->exp_mdt_data;
- struct obd_device *obd = exp->exp_obd;
- struct mdt_device *mdt;
- struct mdt_thread_info *info;
- struct lu_env env;
- CFS_LIST_HEAD(closing_list);
- struct mdt_file_data *mfd, *n;
- int rc = 0;
- ENTRY;
+ struct list_head closing_list;
+ struct mdt_export_data *med = &exp->exp_mdt_data;
+ struct obd_device *obd = exp->exp_obd;
+ struct mdt_device *mdt;
+ struct mdt_thread_info *info;
+ struct lu_env env;
+ struct mdt_file_data *mfd, *n;
+ int rc = 0;
+ ENTRY;
+ INIT_LIST_HEAD(&closing_list);
spin_lock(&med->med_open_lock);
- while (!cfs_list_empty(&med->med_open_head)) {
- cfs_list_t *tmp = med->med_open_head.next;
- mfd = cfs_list_entry(tmp, struct mdt_file_data, mfd_list);
+ while (!list_empty(&med->med_open_head)) {
+ struct list_head *tmp = med->med_open_head.next;
+ mfd = list_entry(tmp, struct mdt_file_data, mfd_list);
/* Remove mfd handle so it can't be found again.
* We are consuming the mfd_list reference here. */
class_handle_unhash(&mfd->mfd_handle);
- cfs_list_move_tail(&mfd->mfd_list, &closing_list);
+ list_move_tail(&mfd->mfd_list, &closing_list);
}
spin_unlock(&med->med_open_lock);
mdt = mdt_dev(obd->obd_lu_dev);
info->mti_mdt = mdt;
info->mti_exp = exp;
- if (!cfs_list_empty(&closing_list)) {
- struct md_attr *ma = &info->mti_attr;
+ if (!list_empty(&closing_list)) {
+ struct md_attr *ma = &info->mti_attr;
- /* Close any open files (which may also cause orphan unlinking). */
- cfs_list_for_each_entry_safe(mfd, n, &closing_list, mfd_list) {
- cfs_list_del_init(&mfd->mfd_list);
+ /* Close any open files (which may also cause orphan
+ * unlinking). */
+ list_for_each_entry_safe(mfd, n, &closing_list, mfd_list) {
+ list_del_init(&mfd->mfd_list);
ma->ma_need = ma->ma_valid = 0;
/* This file is being closed due to an eviction, it
LASSERT(exp);
class_export_get(exp);
+ nodemap_del_member(exp);
rc = server_disconnect_export(exp);
if (rc != 0)
CDEBUG(D_IOCTL, "server disconnect error: rc = %d\n", rc);
RETURN(rc);
}
+/* mds_connect copy */
+static int mdt_obd_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 *lexp;
+ struct lustre_handle conn = { 0 };
+ struct mdt_device *mdt;
+ int rc;
+ lnet_nid_t *client_nid = localdata;
+ ENTRY;
+
+ LASSERT(env != NULL);
+ if (!exp || !obd || !cluuid)
+ RETURN(-EINVAL);
+
+ mdt = mdt_dev(obd->obd_lu_dev);
+
+ /*
+ * first, check whether the stack is ready to handle requests
+ * XXX: probably not very appropriate method is used now
+ * at some point we should find a better one
+ */
+ if (!test_bit(MDT_FL_SYNCED, &mdt->mdt_state) && data != NULL &&
+ !(data->ocd_connect_flags & OBD_CONNECT_LIGHTWEIGHT)) {
+ rc = obd_get_info(env, mdt->mdt_child_exp,
+ sizeof(KEY_OSP_CONNECTED),
+ KEY_OSP_CONNECTED, NULL, NULL, NULL);
+ if (rc)
+ RETURN(-EAGAIN);
+ set_bit(MDT_FL_SYNCED, &mdt->mdt_state);
+ }
+
+ rc = class_connect(&conn, obd, cluuid);
+ if (rc)
+ RETURN(rc);
+
+ lexp = class_conn2export(&conn);
+ LASSERT(lexp != NULL);
+
+ rc = mdt_connect_internal(lexp, mdt, data);
+ if (rc == 0) {
+ struct lsd_client_data *lcd = lexp->exp_target_data.ted_lcd;
+
+ LASSERT(lcd);
+ memcpy(lcd->lcd_uuid, cluuid, sizeof lcd->lcd_uuid);
+ rc = tgt_client_new(env, lexp);
+ if (rc == 0) {
+ rc = nodemap_add_member(*client_nid, lexp);
+ if (rc != 0 && rc != -EEXIST)
+ goto out;
+
+ mdt_export_stats_init(obd, lexp, localdata);
+ }
+
+ /* For phase I, sync for cross-ref operation. */
+ spin_lock(&lexp->exp_lock);
+ lexp->exp_keep_sync = 1;
+ spin_unlock(&lexp->exp_lock);
+ }
+out:
+ if (rc != 0) {
+ class_disconnect(lexp);
+ *exp = NULL;
+ } else {
+ *exp = lexp;
+ }
+
+ RETURN(rc);
+}
+
+static int mdt_obd_reconnect(const struct lu_env *env,
+ struct obd_export *exp, struct obd_device *obd,
+ struct obd_uuid *cluuid,
+ struct obd_connect_data *data,
+ void *localdata)
+{
+ lnet_nid_t *client_nid = localdata;
+ int rc;
+ ENTRY;
+
+ if (exp == NULL || obd == NULL || cluuid == NULL)
+ RETURN(-EINVAL);
+
+ rc = mdt_connect_internal(exp, mdt_dev(obd->obd_lu_dev), data);
+ if (rc == 0) {
+ rc = nodemap_add_member(*client_nid, exp);
+ if (rc == 0 || rc == -EEXIST)
+ mdt_export_stats_init(obd, exp, localdata);
+ }
+
+ RETURN(rc);
+}
+
/* FIXME: Can we avoid using these two interfaces? */
static int mdt_init_export(struct obd_export *exp)
{
- struct mdt_export_data *med = &exp->exp_mdt_data;
- int rc;
- ENTRY;
+ struct mdt_export_data *med = &exp->exp_mdt_data;
+ int rc;
+ ENTRY;
- CFS_INIT_LIST_HEAD(&med->med_open_head);
+ INIT_LIST_HEAD(&med->med_open_head);
spin_lock_init(&med->med_open_lock);
mutex_init(&med->med_idmap_mutex);
med->med_idmap = NULL;
&exp->exp_client_uuid)))
RETURN(0);
- ldlm_destroy_export(exp);
- tgt_client_free(exp);
+ ldlm_destroy_export(exp);
+ tgt_client_free(exp);
- LASSERT(cfs_list_empty(&exp->exp_outstanding_replies));
- LASSERT(cfs_list_empty(&exp->exp_mdt_data.med_open_head));
+ LASSERT(list_empty(&exp->exp_outstanding_replies));
+ LASSERT(list_empty(&exp->exp_mdt_data.med_open_head));
- RETURN(0);
+ RETURN(0);
}
/** The maximum depth that fid2path() will search.
GOTO(lu_fini, rc);
rc = class_register_type(&mdt_obd_device_ops, NULL, true, NULL,
-#ifndef HAVE_ONLY_PROCFS_SEQ
- NULL,
-#endif
LUSTRE_MDT_NAME, &mdt_device_type);
if (rc)
GOTO(mds_fini, rc);