#include <linux/module.h>
#include <obd_class.h>
+#include <lustre_ioctl.h>
#include <lustre_mds.h>
#include <obd_support.h>
#include <lu_object.h>
#include "mdd_internal.h"
-const struct md_device_operations mdd_ops;
+static const struct md_device_operations mdd_ops;
static struct lu_device_type mdd_device_type;
static const char mdd_root_dir_name[] = "ROOT";
static struct lu_device *mdd_device_fini(const struct lu_env *env,
struct lu_device *d)
{
- struct mdd_device *mdd = lu2mdd_dev(d);
- int rc;
+ struct mdd_device *mdd = lu2mdd_dev(d);
if (d->ld_site)
lu_dev_del_linkage(d->ld_site, d);
- rc = mdd_procfs_fini(mdd);
- if (rc) {
- CERROR("proc fini error %d \n", rc);
- return ERR_PTR(rc);
- }
+ mdd_procfs_fini(mdd);
return NULL;
}
static int llog_changelog_cancel(const struct lu_env *env,
struct llog_ctxt *ctxt,
- struct lov_stripe_md *lsm, int count,
struct llog_cookie *cookies, int flags)
{
struct llog_handle *cathandle = ctxt->loc_handle;
static struct llog_operations changelog_orig_logops;
-int mdd_changelog_on(const struct lu_env *env, struct mdd_device *mdd, int on);
+static int
+mdd_changelog_on(const struct lu_env *env, struct mdd_device *mdd, int on);
static int mdd_changelog_llog_init(const struct lu_env *env,
struct mdd_device *mdd)
}
}
-int mdd_changelog_write_header(const struct lu_env *env,
- struct mdd_device *mdd, int markerflags);
+static int
+mdd_changelog_write_header(const struct lu_env *env, struct mdd_device *mdd,
+ int markerflags);
/* Start / stop recording */
-int mdd_changelog_on(const struct lu_env *env, struct mdd_device *mdd, int on)
+static int
+mdd_changelog_on(const struct lu_env *env, struct mdd_device *mdd, int on)
{
int rc = 0;
* \param endrec
* \retval 0 ok
*/
-int mdd_changelog_llog_cancel(const struct lu_env *env,
- struct mdd_device *mdd, long long endrec)
+static int
+mdd_changelog_llog_cancel(const struct lu_env *env, struct mdd_device *mdd,
+ long long endrec)
{
struct obd_device *obd = mdd2obd_dev(mdd);
struct llog_ctxt *ctxt;
changed since the last purge) */
mdd->mdd_cl.mc_starttime = cfs_time_current_64();
- rc = llog_cancel(env, ctxt, NULL, 1, (struct llog_cookie *)&endrec, 0);
+ rc = llog_cancel(env, ctxt, (struct llog_cookie *)&endrec, 0);
out:
llog_ctxt_put(ctxt);
return rc;
ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
LASSERT(ctxt);
- rc = llog_cat_add(env, ctxt->loc_handle, &rec->cr_hdr, NULL, NULL);
+ rc = llog_cat_add(env, ctxt->loc_handle, &rec->cr_hdr, NULL);
if (rc > 0)
rc = 0;
llog_ctxt_put(ctxt);
sscanf(name, SFID, RFID(f));
if (!fid_is_sane(f)) {
- CWARN("%s: bad FID format [%s], should be "DFID"\n",
- mdd2obd_dev(mdd)->obd_name, lname->ln_name,
+ CWARN("%s: Trying to lookup invalid FID [%s] in %s/%s, FID "
+ "format should be "DFID"\n", mdd2obd_dev(mdd)->obd_name,
+ lname->ln_name, dot_lustre_name, mdd_obf_dir_name,
(__u64)FID_SEQ_NORMAL, 1, 0);
GOTO(out, rc = -EINVAL);
}
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),
- (__u64)FID_SEQ_NORMAL, (__u64)FID_SEQ_IGIF,
- (__u64)FID_SEQ_IGIF_MAX);
+ CWARN("%s: Trying to lookup invalid FID "DFID" in %s/%s, "
+ "sequence should be >= "LPX64" or within ["LPX64","
+ ""LPX64"].\n", mdd2obd_dev(mdd)->obd_name, PFID(f),
+ dot_lustre_name, mdd_obf_dir_name, (__u64)FID_SEQ_NORMAL,
+ (__u64)FID_SEQ_IGIF, (__u64)FID_SEQ_IGIF_MAX);
GOTO(out, rc = -EINVAL);
}
static void mdd_device_shutdown(const struct lu_env *env, struct mdd_device *m,
struct lustre_cfg *cfg)
{
+ mdd_generic_thread_stop(&m->mdd_orph_cleanup_thread);
lfsck_degister(env, m->mdd_bottom);
mdd_hsm_actions_llog_fini(env, m);
mdd_changelog_fini(env, m);
orph_index_fini(env, m);
mdd_dot_lustre_cleanup(env, m);
- if (m->mdd_los != NULL)
+ if (m->mdd_los != NULL) {
local_oid_storage_fini(env, m->mdd_los);
+ m->mdd_los = NULL;
+ }
lu_site_purge(env, mdd2lu_dev(m)->ld_site, ~0);
if (m->mdd_child_exp)
ENTRY;
switch (cfg->lcfg_command) {
- case LCFG_PARAM: {
- struct lprocfs_static_vars lvars;
-
- lprocfs_mdd_init_vars(&lvars);
- rc = class_process_proc_param(PARAM_MDD, lvars.obd_vars, cfg,m);
- if (rc > 0 || rc == -ENOSYS)
- /* we don't understand; pass it on */
- rc = next->ld_ops->ldo_process_config(env, next, cfg);
- break;
- }
+ case LCFG_PARAM: {
+ struct obd_device *obd = mdd2obd_dev(m);
+
+ rc = class_process_proc_seq_param(PARAM_MDD, obd->obd_vars,
+ cfg, m);
+ if (rc > 0 || rc == -ENOSYS)
+ /* we don't understand; pass it on */
+ rc = next->ld_ops->ldo_process_config(env, next, cfg);
+ break;
+ }
case LCFG_SETUP:
rc = next->ld_ops->ldo_process_config(env, next, cfg);
if (rc)
next = &mdd->mdd_child->dd_lu_dev;
/* XXX: orphans handling. */
- __mdd_orphan_cleanup(env, mdd);
+ mdd_orphan_cleanup(env, mdd);
rc = next->ld_ops->ldo_recovery_complete(env, next);
RETURN(rc);
rec->cur_endrec = mdd->mdd_cl.mc_index;
spin_unlock(&mdd->mdd_cl.mc_user_lock);
- rc = llog_cat_add(env, ctxt->loc_handle, &rec->cur_hdr, NULL, NULL);
+ rc = llog_cat_add(env, ctxt->loc_handle, &rec->cur_hdr, NULL);
CDEBUG(D_IOCTL, "Registered changelog user %d\n", *id);
out:
CDEBUG(D_IOCTL, "Rewriting changelog user %d endrec to "LPU64"\n",
mcud->mcud_id, rec->cur_endrec);
- /* hdr+1 is loc of data */
- hdr->lrh_len -= sizeof(*hdr) + sizeof(struct llog_rec_tail);
- rc = llog_write(env, llh, hdr, NULL, 0, (void *)(hdr + 1),
- hdr->lrh_index);
+ rc = llog_write(env, llh, hdr, hdr->lrh_index);
RETURN(rc);
}
/* type constructor/destructor: mdd_type_init, mdd_type_fini */
LU_TYPE_INIT_FINI(mdd, &mdd_thread_key);
-const struct md_device_operations mdd_ops = {
+static const struct md_device_operations mdd_ops = {
.mdo_statfs = mdd_statfs,
.mdo_root_get = mdd_root_get,
.mdo_init_capa_ctxt = mdd_init_capa_ctxt,
/* context key: mdd_thread_key */
LU_CONTEXT_KEY_DEFINE(mdd, LCT_MD_THREAD);
+int mdd_generic_thread_start(struct mdd_generic_thread *thread,
+ int (*func)(void *), void *data, char *name)
+{
+ struct task_struct *task;
+
+ LASSERT(thread->mgt_init == false);
+ init_completion(&thread->mgt_started);
+ init_completion(&thread->mgt_finished);
+ thread->mgt_data = data;
+ thread->mgt_abort = false;
+ thread->mgt_init = true;
+
+ task = kthread_run(func, thread, name);
+ if (IS_ERR(task)) {
+ complete(&thread->mgt_finished);
+ return PTR_ERR(task);
+ }
+ wait_for_completion(&thread->mgt_started);
+ return 0;
+}
+
+void mdd_generic_thread_stop(struct mdd_generic_thread *thread)
+{
+ if (thread->mgt_init == true) {
+ thread->mgt_abort = true;
+ wait_for_completion(&thread->mgt_finished);
+ }
+}
+
static int __init mdd_mod_init(void)
{
- struct lprocfs_static_vars lvars;
int rc;
- lprocfs_mdd_init_vars(&lvars);
-
rc = lu_kmem_init(mdd_caches);
if (rc)
return rc;
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,
+ rc = class_register_type(&mdd_obd_device_ops, NULL, true, NULL,
#ifndef HAVE_ONLY_PROCFS_SEQ
- lvars.module_vars,
+ NULL,
#endif
- LUSTRE_MDD_NAME, &mdd_device_type);
+ LUSTRE_MDD_NAME, &mdd_device_type);
if (rc)
lu_kmem_fini(mdd_caches);
return rc;