X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fmdd%2Fmdd_device.c;h=1d049eac833ba95f2f9ef3c881eca26fc794e3d6;hp=c327c9b97f11eff3cb4f13c0d529d0b276cbffb1;hb=df1d59429cbfd1ea2464e863458b6a4a268e516b;hpb=1b2547843817b4b7adbeb87ea9b070d9cac35c90 diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index c327c9b..1d049ea 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -196,6 +196,8 @@ static int changelog_user_init_cb(const struct lu_env *env, spin_lock(&mdd->mdd_cl.mc_user_lock); mdd->mdd_cl.mc_lastuser = rec->cur_id; + if (rec->cur_endrec > mdd->mdd_cl.mc_index) + mdd->mdd_cl.mc_index = rec->cur_endrec; spin_unlock(&mdd->mdd_cl.mc_user_lock); return LLOG_PROC_BREAK; @@ -562,7 +564,8 @@ static int obf_lookup(const struct lu_env *env, struct md_object *p, GOTO(out, rc = -EINVAL); } - if (!fid_is_norm(f) && !fid_is_igif(f) && !fid_is_root(f)) { + if (!fid_is_norm(f) && !fid_is_igif(f) && !fid_is_root(f) && + !fid_seq_is_dot(f->f_seq)) { CWARN("%s: "DFID" is invalid, sequence should be " ">= "LPX64" or within ["LPX64","LPX64"].\n", mdd2obd_dev(mdd)->obd_name, PFID(f), @@ -707,10 +710,84 @@ out: return rc; } + +static struct llog_operations hsm_actions_logops; + +/** + * set llog methods and create LLOG_AGENT_ORIG_CTXT llog + * object in obd_device + */ +static int mdd_hsm_actions_llog_init(const struct lu_env *env, + struct mdd_device *m) +{ + struct obd_device *obd = mdd2obd_dev(m); + struct llog_ctxt *ctxt = NULL; + int rc; + ENTRY; + + OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt); + obd->obd_lvfs_ctxt.dt = m->mdd_bottom; + + rc = llog_setup(env, obd, &obd->obd_olg, LLOG_AGENT_ORIG_CTXT, + obd, &hsm_actions_logops); + if (rc) { + CERROR("%s: hsm actions llog setup failed: rc = %d\n", + obd->obd_name, rc); + RETURN(rc); + } + + ctxt = llog_get_context(obd, LLOG_AGENT_ORIG_CTXT); + LASSERT(ctxt); + + rc = llog_open_create(env, ctxt, &ctxt->loc_handle, NULL, + HSM_ACTIONS); + if (rc) { + CERROR("%s: hsm actions llog open_create failed: rc = %d\n", + obd->obd_name, rc); + GOTO(out_cleanup, rc); + } + + rc = llog_cat_init_and_process(env, ctxt->loc_handle); + if (rc) + GOTO(out_close, rc); + + llog_ctxt_put(ctxt); + RETURN(0); + +out_close: + llog_cat_close(env, ctxt->loc_handle); + ctxt->loc_handle = NULL; +out_cleanup: + llog_cleanup(env, ctxt); + + return rc; +} + +/** + * cleanup the context created by llog_setup_named() + */ +static int mdd_hsm_actions_llog_fini(const struct lu_env *env, + struct mdd_device *m) +{ + struct obd_device *obd = mdd2obd_dev(m); + struct llog_ctxt *lctxt; + ENTRY; + + lctxt = llog_get_context(obd, LLOG_AGENT_ORIG_CTXT); + if (lctxt) { + llog_cat_close(env, lctxt->loc_handle); + lctxt->loc_handle = NULL; + llog_cleanup(env, lctxt); + } + + RETURN(0); +} + static void mdd_device_shutdown(const struct lu_env *env, struct mdd_device *m, struct lustre_cfg *cfg) { lfsck_degister(env, m->mdd_bottom); + mdd_hsm_actions_llog_fini(env, m); mdd_changelog_fini(env, m); orph_index_fini(env, m); if (m->mdd_dot_lustre_objs.mdd_obf) @@ -844,8 +921,8 @@ static int mdd_prepare(const struct lu_env *env, if (rc < 0) GOTO(out_los, rc); + lu_root_fid(&fid); if (mdd_seq_site(mdd)->ss_node_id == 0) { - lu_root_fid(&fid); rc = mdd_local_file_create(env, mdd, &mdd->mdd_local_root_fid, mdd_root_dir_name, S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO, &fid); @@ -854,8 +931,8 @@ static int mdd_prepare(const struct lu_env *env, mdd2obd_dev(mdd)->obd_name, rc); GOTO(out_los, rc); } - mdd->mdd_root_fid = fid; + mdd->mdd_root_fid = fid; rc = mdd_dot_lustre_setup(env, mdd); if (rc != 0) { CERROR("%s: initializing .lustre failed: rc = %d\n", @@ -867,6 +944,10 @@ static int mdd_prepare(const struct lu_env *env, if (rc) GOTO(out_los, rc); + } else { + /* Normal client usually send root access to MDT0 directly, + * the root FID on non-MDT0 will only be used by echo client. */ + mdd->mdd_root_fid = fid; } rc = orph_index_init(env, mdd); @@ -880,13 +961,19 @@ static int mdd_prepare(const struct lu_env *env, GOTO(out_orph, rc); } + rc = mdd_hsm_actions_llog_init(env, mdd); + if (rc != 0) + GOTO(out_changelog, rc); + rc = lfsck_register(env, mdd->mdd_bottom, mdd->mdd_child, true); if (rc != 0) { CERROR("%s: failed to initialize lfsck: rc = %d\n", mdd2obd_dev(mdd)->obd_name, rc); - GOTO(out_changelog, rc); + GOTO(out_hsm, rc); } RETURN(0); +out_hsm: + mdd_hsm_actions_llog_fini(env, mdd); out_changelog: mdd_changelog_fini(env, mdd); out_orph: @@ -901,6 +988,7 @@ out_dot: out_los: local_oid_storage_fini(env, mdd->mdd_los); mdd->mdd_los = NULL; + return rc; } @@ -925,16 +1013,18 @@ static int mdd_root_get(const struct lu_env *env, * No permission check is needed. */ static int mdd_statfs(const struct lu_env *env, struct md_device *m, - struct obd_statfs *sfs) + struct obd_statfs *sfs) { - struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev); - int rc; + struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev); + int rc; - ENTRY; + ENTRY; - rc = mdd_child_ops(mdd)->dt_statfs(env, mdd->mdd_child, sfs); + rc = mdd_child_ops(mdd)->dt_statfs(env, mdd->mdd_child, sfs); - RETURN(rc); + sfs->os_namelen = min_t(__u32, sfs->os_namelen, NAME_MAX); + + RETURN(rc); } /* @@ -955,6 +1045,17 @@ static int mdd_init_capa_ctxt(const struct lu_env *env, struct md_device *m, RETURN(rc); } +static int mdd_maxeasize_get(const struct lu_env *env, struct md_device *m, + int *easize) +{ + struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev); + ENTRY; + + *easize = mdd->mdd_dt_conf.ddp_max_ea_size; + + RETURN(0); +} + static int mdd_update_capa_key(const struct lu_env *env, struct md_device *m, struct lustre_capa_key *key) @@ -978,7 +1079,7 @@ static struct lu_device *mdd_device_free(const struct lu_env *env, struct mdd_device *m = lu2mdd_dev(lu); ENTRY; - LASSERT(cfs_atomic_read(&lu->ld_ref) == 0); + LASSERT(atomic_read(&lu->ld_ref) == 0); md_device_fini(&m->mdd_md_dev); OBD_FREE_PTR(m); RETURN(NULL); @@ -1058,15 +1159,26 @@ static int mdd_obd_disconnect(struct obd_export *exp) RETURN(rc); } -static int mdd_obd_health_check(const struct lu_env *env, - struct obd_device *obd) +static int mdd_obd_get_info(const struct lu_env *env, struct obd_export *exp, + __u32 keylen, void *key, __u32 *vallen, void *val, + struct lov_stripe_md *lsm) { - struct mdd_device *mdd = lu2mdd_dev(obd->obd_lu_dev); - int rc; - ENTRY; + int rc = -EINVAL; + + if (KEY_IS(KEY_OSP_CONNECTED)) { + struct obd_device *obd = exp->exp_obd; + struct mdd_device *mdd; + + if (!obd->obd_set_up || obd->obd_stopping) + RETURN(-EAGAIN); + + mdd = lu2mdd_dev(obd->obd_lu_dev); + LASSERT(mdd); + rc = obd_get_info(env, mdd->mdd_child_exp, keylen, key, vallen, + val, lsm); + RETURN(rc); + } - LASSERT(mdd); - rc = obd_health_check(env, mdd->mdd_child_exp->exp_obd); RETURN(rc); } @@ -1074,30 +1186,9 @@ static struct obd_ops mdd_obd_device_ops = { .o_owner = THIS_MODULE, .o_connect = mdd_obd_connect, .o_disconnect = mdd_obd_disconnect, - .o_health_check = mdd_obd_health_check -}; - -/* - * context key constructor/destructor: - * mdd_capainfo_key_init, mdd_capainfo_key_fini - */ -LU_KEY_INIT_FINI(mdd_capainfo, struct md_capainfo); - -struct lu_context_key mdd_capainfo_key = { - .lct_tags = LCT_SESSION, - .lct_init = mdd_capainfo_key_init, - .lct_fini = mdd_capainfo_key_fini + .o_get_info = mdd_obd_get_info, }; -struct md_capainfo *md_capainfo(const struct lu_env *env) -{ - /* NB, in mdt_init0 */ - if (env->le_ses == NULL) - return NULL; - return lu_context_key_get(env->le_ses, &mdd_capainfo_key); -} -EXPORT_SYMBOL(md_capainfo); - static int mdd_changelog_user_register(const struct lu_env *env, struct mdd_device *mdd, int *id) { @@ -1350,7 +1441,7 @@ static int mdd_iocontrol(const struct lu_env *env, struct md_device *m, } /* type constructor/destructor: mdd_type_init, mdd_type_fini */ -LU_TYPE_INIT_FINI(mdd, &mdd_thread_key, &mdd_capainfo_key); +LU_TYPE_INIT_FINI(mdd, &mdd_thread_key); const struct md_device_operations mdd_ops = { .mdo_statfs = mdd_statfs, @@ -1359,6 +1450,7 @@ const struct md_device_operations mdd_ops = { .mdo_update_capa_key= mdd_update_capa_key, .mdo_llog_ctxt_get = mdd_llog_ctxt_get, .mdo_iocontrol = mdd_iocontrol, + .mdo_maxeasize_get = mdd_maxeasize_get, }; static struct lu_device_type_operations mdd_device_type_ops = { @@ -1414,8 +1506,15 @@ static int __init mdd_mod_init(void) changelog_orig_logops.lop_add = llog_cat_add_rec; changelog_orig_logops.lop_declare_add = llog_cat_declare_add_rec; - rc = class_register_type(&mdd_obd_device_ops, NULL, lvars.module_vars, - LUSTRE_MDD_NAME, &mdd_device_type); + hsm_actions_logops = llog_osd_ops; + hsm_actions_logops.lop_add = llog_cat_add_rec; + hsm_actions_logops.lop_declare_add = llog_cat_declare_add_rec; + + rc = class_register_type(&mdd_obd_device_ops, NULL, NULL, +#ifndef HAVE_ONLY_PROCFS_SEQ + lvars.module_vars, +#endif + LUSTRE_MDD_NAME, &mdd_device_type); if (rc) lu_kmem_fini(mdd_caches); return rc;