4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2014, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/mdd/mdd_device.c
38 * Lustre Metadata Server (mdd) routines
40 * Author: Wang Di <wangdi@clusterfs.com>
43 #define DEBUG_SUBSYSTEM S_MDS
45 #include <linux/module.h>
46 #include <linux/kthread.h>
47 #include <obd_class.h>
48 #include <lustre_ioctl.h>
49 #include <lustre_mds.h>
50 #include <obd_support.h>
51 #include <lu_object.h>
52 #include <lustre_param.h>
53 #include <lustre_fid.h>
55 #include "mdd_internal.h"
57 static const struct md_device_operations mdd_ops;
58 static struct lu_device_type mdd_device_type;
60 static const char mdd_root_dir_name[] = "ROOT";
61 static const char mdd_obf_dir_name[] = "fid";
62 static const char mdd_lpf_dir_name[] = "lost+found";
64 /* Slab for MDD object allocation */
65 struct kmem_cache *mdd_object_kmem;
67 static struct lu_kmem_descr mdd_caches[] = {
69 .ckd_cache = &mdd_object_kmem,
70 .ckd_name = "mdd_obj",
71 .ckd_size = sizeof(struct mdd_object)
78 static int mdd_connect_to_next(const struct lu_env *env, struct mdd_device *m,
81 struct obd_connect_data *data = NULL;
82 struct lu_device *lud = mdd2lu_dev(m);
83 struct obd_device *obd;
87 LASSERT(m->mdd_child_exp == NULL);
89 OBD_ALLOC(data, sizeof(*data));
91 GOTO(out, rc = -ENOMEM);
93 obd = class_name2obd(nextdev);
95 CERROR("can't locate next device: %s\n", nextdev);
96 GOTO(out, rc = -ENOTCONN);
99 data->ocd_connect_flags = OBD_CONNECT_VERSION;
100 data->ocd_version = LUSTRE_VERSION_CODE;
102 rc = obd_connect(NULL, &m->mdd_child_exp, obd, &obd->obd_uuid, data, NULL);
104 CERROR("cannot connect to next dev %s (%d)\n", nextdev, rc);
108 lud->ld_site = m->mdd_child_exp->exp_obd->obd_lu_dev->ld_site;
109 LASSERT(lud->ld_site);
110 m->mdd_child = lu2dt_dev(m->mdd_child_exp->exp_obd->obd_lu_dev);
111 m->mdd_bottom = lu2dt_dev(lud->ld_site->ls_bottom_dev);
112 lu_dev_add_linkage(lud->ld_site, lud);
116 OBD_FREE(data, sizeof(*data));
120 static int mdd_init0(const struct lu_env *env, struct mdd_device *mdd,
121 struct lu_device_type *t, struct lustre_cfg *lcfg)
127 /* LU-8040 Set defaults here, before values configs */
128 mdd->mdd_cl.mc_flags = 0; /* off by default */
129 mdd->mdd_cl.mc_mask = CHANGELOG_DEFMASK;
131 dev = lustre_cfg_string(lcfg, 0);
135 mdd->mdd_md_dev.md_lu_dev.ld_obd = class_name2obd(dev);
136 if (mdd->mdd_md_dev.md_lu_dev.ld_obd == NULL)
138 mdd->mdd_md_dev.md_lu_dev.ld_ops = &mdd_lu_ops;
139 mdd->mdd_md_dev.md_ops = &mdd_ops;
141 rc = mdd_connect_to_next(env, mdd, lustre_cfg_string(lcfg, 3));
145 mdd->mdd_atime_diff = MAX_ATIME_DIFF;
146 /* sync permission changes */
147 mdd->mdd_sync_permission = 1;
149 dt_conf_get(env, mdd->mdd_child, &mdd->mdd_dt_conf);
151 /* we are using service name but not mdd obd name
152 * for compatibility reasons.
153 * It is passed from MDT in lustre_cfg[2] buffer */
154 rc = mdd_procfs_init(mdd, lustre_cfg_string(lcfg, 2));
156 obd_disconnect(mdd->mdd_child_exp);
161 static struct lu_device *mdd_device_fini(const struct lu_env *env,
164 struct mdd_device *mdd = lu2mdd_dev(d);
167 lu_dev_del_linkage(d->ld_site, d);
169 mdd_procfs_fini(mdd);
173 static int changelog_init_cb(const struct lu_env *env, struct llog_handle *llh,
174 struct llog_rec_hdr *hdr, void *data)
176 struct mdd_device *mdd = (struct mdd_device *)data;
177 struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
179 LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
180 LASSERT(rec->cr_hdr.lrh_type == CHANGELOG_REC);
183 "seeing record at index %d/%d/"LPU64" t=%x %.*s in log"
184 DOSTID"\n", hdr->lrh_index, rec->cr_hdr.lrh_index,
185 rec->cr.cr_index, rec->cr.cr_type, rec->cr.cr_namelen,
186 changelog_rec_name(&rec->cr), POSTID(&llh->lgh_id.lgl_oi));
188 mdd->mdd_cl.mc_index = rec->cr.cr_index;
189 return LLOG_PROC_BREAK;
192 static int changelog_user_init_cb(const struct lu_env *env,
193 struct llog_handle *llh,
194 struct llog_rec_hdr *hdr, void *data)
196 struct mdd_device *mdd = (struct mdd_device *)data;
197 struct llog_changelog_user_rec *rec =
198 (struct llog_changelog_user_rec *)hdr;
200 LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
201 LASSERT(rec->cur_hdr.lrh_type == CHANGELOG_USER_REC);
203 CDEBUG(D_INFO, "seeing user at index %d/%d id=%d endrec="LPU64
204 " in log "DOSTID"\n", hdr->lrh_index, rec->cur_hdr.lrh_index,
205 rec->cur_id, rec->cur_endrec, POSTID(&llh->lgh_id.lgl_oi));
207 spin_lock(&mdd->mdd_cl.mc_user_lock);
208 mdd->mdd_cl.mc_lastuser = rec->cur_id;
209 if (rec->cur_endrec > mdd->mdd_cl.mc_index)
210 mdd->mdd_cl.mc_index = rec->cur_endrec;
211 spin_unlock(&mdd->mdd_cl.mc_user_lock);
213 return LLOG_PROC_BREAK;
216 static int llog_changelog_cancel_cb(const struct lu_env *env,
217 struct llog_handle *llh,
218 struct llog_rec_hdr *hdr, void *data)
220 struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
221 struct llog_cookie cookie;
222 long long endrec = *(long long *)data;
227 /* This is always a (sub)log, not the catalog */
228 LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
230 if (rec->cr.cr_index > endrec)
231 /* records are in order, so we're done */
232 RETURN(LLOG_PROC_BREAK);
234 cookie.lgc_lgl = llh->lgh_id;
235 cookie.lgc_index = hdr->lrh_index;
237 /* cancel them one at a time. I suppose we could store up the cookies
238 * and cancel them all at once; probably more efficient, but this is
239 * done as a user call, so who cares... */
240 rc = llog_cat_cancel_records(env, llh->u.phd.phd_cat_handle, 1,
242 RETURN(rc < 0 ? rc : 0);
245 static int llog_changelog_cancel(const struct lu_env *env,
246 struct llog_ctxt *ctxt,
247 struct llog_cookie *cookies, int flags)
249 struct llog_handle *cathandle = ctxt->loc_handle;
254 /* This should only be called with the catalog handle */
255 LASSERT(cathandle->lgh_hdr->llh_flags & LLOG_F_IS_CAT);
257 rc = llog_cat_process(env, cathandle, llog_changelog_cancel_cb,
258 (void *)cookies, 0, 0);
260 /* 0 or 1 means we're done */
263 CERROR("%s: cancel idx %u of catalog "DOSTID" rc=%d\n",
264 ctxt->loc_obd->obd_name, cathandle->lgh_last_idx,
265 POSTID(&cathandle->lgh_id.lgl_oi), rc);
270 static struct llog_operations changelog_orig_logops;
273 mdd_changelog_write_header(const struct lu_env *env, struct mdd_device *mdd,
277 mdd_changelog_on(const struct lu_env *env, struct mdd_device *mdd)
281 if ((mdd->mdd_cl.mc_flags & CLM_ON) != 0)
284 LCONSOLE_INFO("%s: changelog on\n", mdd2obd_dev(mdd)->obd_name);
285 if (mdd->mdd_cl.mc_flags & CLM_ERR) {
286 CERROR("Changelogs cannot be enabled due to error "
287 "condition (see %s log).\n",
288 mdd2obd_dev(mdd)->obd_name);
291 spin_lock(&mdd->mdd_cl.mc_lock);
292 mdd->mdd_cl.mc_flags |= CLM_ON;
293 spin_unlock(&mdd->mdd_cl.mc_lock);
294 rc = mdd_changelog_write_header(env, mdd, CLM_START);
300 mdd_changelog_off(const struct lu_env *env, struct mdd_device *mdd)
304 if ((mdd->mdd_cl.mc_flags & CLM_ON) != CLM_ON)
307 LCONSOLE_INFO("%s: changelog off\n", mdd2obd_dev(mdd)->obd_name);
308 rc = mdd_changelog_write_header(env, mdd, CLM_FINI);
309 spin_lock(&mdd->mdd_cl.mc_lock);
310 mdd->mdd_cl.mc_flags &= ~CLM_ON;
311 spin_unlock(&mdd->mdd_cl.mc_lock);
316 static int mdd_changelog_llog_init(const struct lu_env *env,
317 struct mdd_device *mdd)
319 struct obd_device *obd = mdd2obd_dev(mdd);
320 struct llog_ctxt *ctxt = NULL, *uctxt = NULL;
325 /* LU-2844 mdd setup failure should not cause umount oops */
326 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_CHANGELOG_INIT))
329 OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
330 obd->obd_lvfs_ctxt.dt = mdd->mdd_bottom;
331 rc = llog_setup(env, obd, &obd->obd_olg, LLOG_CHANGELOG_ORIG_CTXT,
332 obd, &changelog_orig_logops);
334 CERROR("%s: changelog llog setup failed: rc = %d\n",
339 ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
342 rc = llog_open_create(env, ctxt, &ctxt->loc_handle, NULL,
345 GOTO(out_cleanup, rc);
347 rc = llog_init_handle(env, ctxt->loc_handle, LLOG_F_IS_CAT, NULL);
351 rc = llog_cat_reverse_process(env, ctxt->loc_handle,
352 changelog_init_cb, mdd);
355 CERROR("%s: changelog init failed: rc = %d\n", obd->obd_name,
360 CDEBUG(D_IOCTL, "changelog starting index="LPU64"\n",
361 mdd->mdd_cl.mc_index);
363 /* setup user changelog */
364 rc = llog_setup(env, obd, &obd->obd_olg, LLOG_CHANGELOG_USER_ORIG_CTXT,
365 obd, &changelog_orig_logops);
367 CERROR("%s: changelog users llog setup failed: rc = %d\n",
372 uctxt = llog_get_context(obd, LLOG_CHANGELOG_USER_ORIG_CTXT);
375 rc = llog_open_create(env, uctxt, &uctxt->loc_handle, NULL,
378 GOTO(out_ucleanup, rc);
380 uctxt->loc_handle->lgh_logops->lop_add = llog_cat_add_rec;
381 uctxt->loc_handle->lgh_logops->lop_declare_add = llog_cat_declare_add_rec;
383 rc = llog_init_handle(env, uctxt->loc_handle, LLOG_F_IS_CAT, NULL);
385 GOTO(out_uclose, rc);
387 rc = llog_cat_reverse_process(env, uctxt->loc_handle,
388 changelog_user_init_cb, mdd);
390 CERROR("%s: changelog user init failed: rc = %d\n",
392 GOTO(out_uclose, rc);
395 /* If we have registered users, assume we want changelogs on */
396 if (mdd->mdd_cl.mc_lastuser > 0) {
397 rc = mdd_changelog_on(env, mdd);
399 GOTO(out_uclose, rc);
402 llog_ctxt_put(uctxt);
405 llog_cat_close(env, uctxt->loc_handle);
407 llog_cleanup(env, uctxt);
409 llog_cat_close(env, ctxt->loc_handle);
411 llog_cleanup(env, ctxt);
415 static int mdd_changelog_init(const struct lu_env *env, struct mdd_device *mdd)
417 struct obd_device *obd = mdd2obd_dev(mdd);
420 mdd->mdd_cl.mc_index = 0;
421 spin_lock_init(&mdd->mdd_cl.mc_lock);
422 mdd->mdd_cl.mc_starttime = cfs_time_current_64();
423 spin_lock_init(&mdd->mdd_cl.mc_user_lock);
424 mdd->mdd_cl.mc_lastuser = 0;
426 rc = mdd_changelog_llog_init(env, mdd);
428 CERROR("%s: changelog setup during init failed: rc = %d\n",
430 mdd->mdd_cl.mc_flags |= CLM_ERR;
436 static void mdd_changelog_fini(const struct lu_env *env,
437 struct mdd_device *mdd)
439 struct obd_device *obd = mdd2obd_dev(mdd);
440 struct llog_ctxt *ctxt;
442 mdd->mdd_cl.mc_flags = 0;
444 ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
446 llog_cat_close(env, ctxt->loc_handle);
447 llog_cleanup(env, ctxt);
449 ctxt = llog_get_context(obd, LLOG_CHANGELOG_USER_ORIG_CTXT);
451 llog_cat_close(env, ctxt->loc_handle);
452 llog_cleanup(env, ctxt);
456 /** Remove entries with indicies up to and including \a endrec from the
463 mdd_changelog_llog_cancel(const struct lu_env *env, struct mdd_device *mdd,
466 struct obd_device *obd = mdd2obd_dev(mdd);
467 struct llog_ctxt *ctxt;
468 long long unsigned cur;
471 ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
475 spin_lock(&mdd->mdd_cl.mc_lock);
476 cur = (long long)mdd->mdd_cl.mc_index;
477 spin_unlock(&mdd->mdd_cl.mc_lock);
481 /* purge to "0" is shorthand for everything */
485 /* If purging all records, write a header entry so we don't have an
486 empty catalog and we're sure to have a valid starting index next
487 time. In case of crash, we just restart with old log so we're
490 /* XXX: transaction is started by llog itself */
491 rc = mdd_changelog_write_header(env, mdd, CLM_PURGE);
496 /* Some records were purged, so reset repeat-access time (so we
497 record new mtime update records, so users can see a file has been
498 changed since the last purge) */
499 mdd->mdd_cl.mc_starttime = cfs_time_current_64();
501 rc = llog_cancel(env, ctxt, (struct llog_cookie *)&endrec, 0);
507 /** Add a CL_MARK record to the changelog
509 * \param markerflags - CLM_*
512 int mdd_changelog_write_header(const struct lu_env *env,
513 struct mdd_device *mdd, int markerflags)
515 struct obd_device *obd = mdd2obd_dev(mdd);
516 struct llog_changelog_rec *rec;
518 struct llog_ctxt *ctxt;
520 int len = strlen(obd->obd_name);
525 if (mdd->mdd_cl.mc_mask & (1 << CL_MARK)) {
526 mdd->mdd_cl.mc_starttime = cfs_time_current_64();
530 reclen = llog_data_len(sizeof(*rec) + len);
531 buf = lu_buf_check_and_alloc(&mdd_env_info(env)->mti_big_buf, reclen);
532 if (buf->lb_buf == NULL)
536 rec->cr.cr_flags = CLF_VERSION;
537 rec->cr.cr_type = CL_MARK;
538 rec->cr.cr_namelen = len;
539 memcpy(changelog_rec_name(&rec->cr), obd->obd_name, rec->cr.cr_namelen);
540 /* Status and action flags */
541 rec->cr.cr_markerflags = mdd->mdd_cl.mc_flags | markerflags;
542 rec->cr_hdr.lrh_len = llog_data_len(changelog_rec_size(&rec->cr) +
544 rec->cr_hdr.lrh_type = CHANGELOG_REC;
545 rec->cr.cr_time = cl_time();
546 spin_lock(&mdd->mdd_cl.mc_lock);
547 rec->cr.cr_index = ++mdd->mdd_cl.mc_index;
548 spin_unlock(&mdd->mdd_cl.mc_lock);
550 ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
553 rc = llog_cat_add(env, ctxt->loc_handle, &rec->cr_hdr, NULL);
558 /* assume on or off event; reset repeat-access time */
559 mdd->mdd_cl.mc_starttime = cfs_time_current_64();
564 * Lookup method for "fid" object. Only filenames with correct SEQ:OID format
565 * are valid. We also check if object with passed fid exists or not.
567 static int obf_lookup(const struct lu_env *env, struct md_object *p,
568 const struct lu_name *lname, struct lu_fid *f,
569 struct md_op_spec *spec)
571 char *name = (char *)lname->ln_name;
572 struct mdd_device *mdd = mdo2mdd(p);
573 struct mdd_object *child;
579 sscanf(name, SFID, RFID(f));
580 if (!fid_is_sane(f)) {
581 CWARN("%s: Trying to lookup invalid FID [%s] in %s/%s, FID "
582 "format should be "DFID"\n", mdd2obd_dev(mdd)->obd_name,
583 lname->ln_name, dot_lustre_name, mdd_obf_dir_name,
584 (__u64)FID_SEQ_NORMAL, 1, 0);
585 GOTO(out, rc = -EINVAL);
588 if (!fid_is_norm(f) && !fid_is_igif(f) && !fid_is_root(f) &&
589 !fid_seq_is_dot(f->f_seq)) {
590 CWARN("%s: Trying to lookup invalid FID "DFID" in %s/%s, "
591 "sequence should be >= "LPX64" or within ["LPX64","
592 ""LPX64"].\n", mdd2obd_dev(mdd)->obd_name, PFID(f),
593 dot_lustre_name, mdd_obf_dir_name, (__u64)FID_SEQ_NORMAL,
594 (__u64)FID_SEQ_IGIF, (__u64)FID_SEQ_IGIF_MAX);
595 GOTO(out, rc = -EINVAL);
598 /* Check if object with this fid exists */
599 child = mdd_object_find(env, mdd, f);
601 GOTO(out, rc = PTR_ERR(child));
603 if (mdd_object_exists(child) == 0)
606 mdd_object_put(env, child);
612 static int mdd_dummy_create(const struct lu_env *env,
613 struct md_object *pobj,
614 const struct lu_name *lname,
615 struct md_object *child,
616 struct md_op_spec *spec,
622 static int mdd_dummy_rename(const struct lu_env *env,
623 struct md_object *src_pobj,
624 struct md_object *tgt_pobj,
625 const struct lu_fid *lf,
626 const struct lu_name *lsname,
627 struct md_object *tobj,
628 const struct lu_name *ltname,
634 static int mdd_dummy_link(const struct lu_env *env,
635 struct md_object *tgt_obj,
636 struct md_object *src_obj,
637 const struct lu_name *lname,
643 static int mdd_dummy_unlink(const struct lu_env *env,
644 struct md_object *pobj,
645 struct md_object *cobj,
646 const struct lu_name *lname,
653 static struct md_dir_operations mdd_obf_dir_ops = {
654 .mdo_lookup = obf_lookup,
655 .mdo_create = mdd_dummy_create,
656 .mdo_rename = mdd_dummy_rename,
657 .mdo_link = mdd_dummy_link,
658 .mdo_unlink = mdd_dummy_unlink
661 static struct md_dir_operations mdd_lpf_dir_ops = {
662 .mdo_lookup = mdd_lookup,
663 .mdo_create = mdd_dummy_create,
664 .mdo_rename = mdd_dummy_rename,
665 .mdo_link = mdd_dummy_link,
666 .mdo_unlink = mdd_dummy_unlink
669 static struct md_object *mdo_locate(const struct lu_env *env,
670 struct md_device *md,
671 const struct lu_fid *fid)
673 struct lu_object *obj;
674 struct md_object *mdo;
676 obj = lu_object_find(env, &md->md_lu_dev, fid, NULL);
678 obj = lu_object_locate(obj->lo_header, md->md_lu_dev.ld_type);
679 LASSERT(obj != NULL);
682 mdo = ERR_PTR(PTR_ERR(obj));
687 static int mdd_lpf_setup(const struct lu_env *env, struct mdd_device *m)
689 struct md_object *mdo;
690 struct mdd_object *mdd_lpf;
691 struct lu_fid fid = LU_LPF_FID;
695 rc = mdd_local_file_create(env, m, mdd_object_fid(m->mdd_dot_lustre),
696 mdd_lpf_dir_name, S_IFDIR | S_IRUSR | S_IXUSR,
701 mdo = mdo_locate(env, &m->mdd_md_dev, &fid);
703 RETURN(PTR_ERR(mdo));
705 LASSERT(lu_object_exists(&mdo->mo_lu));
707 mdd_lpf = md2mdd_obj(mdo);
708 mdd_lpf->mod_obj.mo_dir_ops = &mdd_lpf_dir_ops;
709 m->mdd_dot_lustre_objs.mdd_lpf = mdd_lpf;
715 * Create special in-memory "fid" object for open-by-fid.
717 static int mdd_obf_setup(const struct lu_env *env, struct mdd_device *m)
719 struct md_object *mdo;
720 struct mdd_object *mdd_obf;
721 struct lu_fid fid = LU_OBF_FID;
724 rc = mdd_local_file_create(env, m, mdd_object_fid(m->mdd_dot_lustre),
725 mdd_obf_dir_name, S_IFDIR | S_IXUSR, &fid);
729 mdo = mdo_locate(env, &m->mdd_md_dev, &fid);
731 RETURN(PTR_ERR(mdo));
733 LASSERT(lu_object_exists(&mdo->mo_lu));
735 mdd_obf = md2mdd_obj(mdo);
736 mdd_obf->mod_obj.mo_dir_ops = &mdd_obf_dir_ops;
737 m->mdd_dot_lustre_objs.mdd_obf = mdd_obf;
742 static void mdd_dot_lustre_cleanup(const struct lu_env *env,
743 struct mdd_device *m)
745 if (m->mdd_dot_lustre_objs.mdd_lpf != NULL) {
746 mdd_object_put(env, m->mdd_dot_lustre_objs.mdd_lpf);
747 m->mdd_dot_lustre_objs.mdd_lpf = NULL;
749 if (m->mdd_dot_lustre_objs.mdd_obf != NULL) {
750 mdd_object_put(env, m->mdd_dot_lustre_objs.mdd_obf);
751 m->mdd_dot_lustre_objs.mdd_obf = NULL;
753 if (m->mdd_dot_lustre != NULL) {
754 mdd_object_put(env, m->mdd_dot_lustre);
755 m->mdd_dot_lustre = NULL;
759 /** Setup ".lustre" directory object */
760 static int mdd_dot_lustre_setup(const struct lu_env *env, struct mdd_device *m)
762 struct md_object *mdo;
767 /* Create ".lustre" directory in ROOT. */
768 fid = LU_DOT_LUSTRE_FID;
769 rc = mdd_local_file_create(env, m, &m->mdd_root_fid,
771 S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO,
775 mdo = mdo_locate(env, &m->mdd_md_dev, &fid);
777 RETURN(PTR_ERR(mdo));
778 LASSERT(lu_object_exists(&mdo->mo_lu));
780 m->mdd_dot_lustre = md2mdd_obj(mdo);
782 rc = mdd_obf_setup(env, m);
784 CERROR("%s: error initializing \"fid\" object: rc = %d.\n",
785 mdd2obd_dev(m)->obd_name, rc);
789 rc = mdd_lpf_setup(env, m);
791 CERROR("%s: error initializing \"lost+found\": rc = %d.\n",
792 mdd2obd_dev(m)->obd_name, rc);
799 mdd_dot_lustre_cleanup(env, m);
805 static struct llog_operations hsm_actions_logops;
808 * set llog methods and create LLOG_AGENT_ORIG_CTXT llog
809 * object in obd_device
811 static int mdd_hsm_actions_llog_init(const struct lu_env *env,
812 struct mdd_device *m)
814 struct obd_device *obd = mdd2obd_dev(m);
815 struct llog_ctxt *ctxt = NULL;
819 OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
820 obd->obd_lvfs_ctxt.dt = m->mdd_bottom;
822 rc = llog_setup(env, obd, &obd->obd_olg, LLOG_AGENT_ORIG_CTXT,
823 obd, &hsm_actions_logops);
825 CERROR("%s: hsm actions llog setup failed: rc = %d\n",
830 ctxt = llog_get_context(obd, LLOG_AGENT_ORIG_CTXT);
833 rc = llog_open_create(env, ctxt, &ctxt->loc_handle, NULL,
836 CERROR("%s: hsm actions llog open_create failed: rc = %d\n",
838 GOTO(out_cleanup, rc);
841 rc = llog_init_handle(env, ctxt->loc_handle, LLOG_F_IS_CAT, NULL);
849 llog_cat_close(env, ctxt->loc_handle);
850 ctxt->loc_handle = NULL;
852 llog_cleanup(env, ctxt);
858 * cleanup the context created by llog_setup_named()
860 static int mdd_hsm_actions_llog_fini(const struct lu_env *env,
861 struct mdd_device *m)
863 struct obd_device *obd = mdd2obd_dev(m);
864 struct llog_ctxt *lctxt;
867 lctxt = llog_get_context(obd, LLOG_AGENT_ORIG_CTXT);
869 llog_cat_close(env, lctxt->loc_handle);
870 lctxt->loc_handle = NULL;
871 llog_cleanup(env, lctxt);
877 static void mdd_device_shutdown(const struct lu_env *env, struct mdd_device *m,
878 struct lustre_cfg *cfg)
880 mdd_generic_thread_stop(&m->mdd_orph_cleanup_thread);
881 lfsck_degister(env, m->mdd_bottom);
882 mdd_hsm_actions_llog_fini(env, m);
883 mdd_changelog_fini(env, m);
884 orph_index_fini(env, m);
885 mdd_dot_lustre_cleanup(env, m);
886 if (m->mdd_los != NULL) {
887 local_oid_storage_fini(env, m->mdd_los);
890 lu_site_purge(env, mdd2lu_dev(m)->ld_site, ~0);
892 if (m->mdd_child_exp)
893 obd_disconnect(m->mdd_child_exp);
896 static int mdd_process_config(const struct lu_env *env,
897 struct lu_device *d, struct lustre_cfg *cfg)
899 struct mdd_device *m = lu2mdd_dev(d);
900 struct dt_device *dt = m->mdd_child;
901 struct lu_device *next = &dt->dd_lu_dev;
905 switch (cfg->lcfg_command) {
907 struct obd_device *obd = mdd2obd_dev(m);
909 rc = class_process_proc_param(PARAM_MDD, obd->obd_vars, cfg, m);
910 if (rc > 0 || rc == -ENOSYS)
911 /* we don't understand; pass it on */
912 rc = next->ld_ops->ldo_process_config(env, next, cfg);
916 rc = next->ld_ops->ldo_process_config(env, next, cfg);
919 dt_conf_get(env, dt, &m->mdd_dt_conf);
922 rc = next->ld_ops->ldo_process_config(env, next, cfg);
923 lu_dev_del_linkage(d->ld_site, d);
924 mdd_device_shutdown(env, m, cfg);
927 rc = next->ld_ops->ldo_process_config(env, next, cfg);
934 static int mdd_recovery_complete(const struct lu_env *env,
937 struct mdd_device *mdd = lu2mdd_dev(d);
938 struct lu_device *next;
942 LASSERT(mdd != NULL);
943 next = &mdd->mdd_child->dd_lu_dev;
945 /* XXX: orphans handling. */
946 mdd_orphan_cleanup(env, mdd);
947 rc = next->ld_ops->ldo_recovery_complete(env, next);
952 int mdd_local_file_create(const struct lu_env *env, struct mdd_device *mdd,
953 const struct lu_fid *pfid, const char *name,
954 __u32 mode, struct lu_fid *fid)
956 struct dt_object *parent, *dto;
961 LASSERT(!fid_is_zero(pfid));
962 parent = dt_locate(env, mdd->mdd_bottom, pfid);
963 if (unlikely(IS_ERR(parent)))
964 RETURN(PTR_ERR(parent));
966 /* create local file/dir, if @fid is passed then try to use it */
967 if (fid_is_zero(fid))
968 dto = local_file_find_or_create(env, mdd->mdd_los, parent,
971 dto = local_file_find_or_create_with_fid(env, mdd->mdd_bottom,
975 GOTO(out_put, rc = PTR_ERR(dto));
976 *fid = *lu_object_fid(&dto->do_lu);
977 /* since stack is not fully set up the local_storage uses own stack
978 * and we should drop its object from cache */
979 lu_object_put_nocache(env, &dto->do_lu);
982 lu_object_put(env, &parent->do_lu);
986 static int mdd_lfsck_out_notify(const struct lu_env *env, void *data,
987 enum lfsck_events event)
992 static int mdd_prepare(const struct lu_env *env,
993 struct lu_device *pdev,
994 struct lu_device *cdev)
996 struct mdd_device *mdd = lu2mdd_dev(cdev);
997 struct lu_device *next = &mdd->mdd_child->dd_lu_dev;
1003 rc = next->ld_ops->ldo_prepare(env, cdev, next);
1007 /* Setup local dirs */
1008 fid.f_seq = FID_SEQ_LOCAL_NAME;
1011 rc = local_oid_storage_init(env, mdd->mdd_bottom, &fid,
1016 rc = dt_root_get(env, mdd->mdd_child, &mdd->mdd_local_root_fid);
1021 if (mdd_seq_site(mdd)->ss_node_id == 0) {
1022 rc = mdd_local_file_create(env, mdd, &mdd->mdd_local_root_fid,
1023 mdd_root_dir_name, S_IFDIR |
1024 S_IRUGO | S_IWUSR | S_IXUGO, &fid);
1026 CERROR("%s: create root fid failed: rc = %d\n",
1027 mdd2obd_dev(mdd)->obd_name, rc);
1031 mdd->mdd_root_fid = fid;
1032 rc = mdd_dot_lustre_setup(env, mdd);
1034 CERROR("%s: initializing .lustre failed: rc = %d\n",
1035 mdd2obd_dev(mdd)->obd_name, rc);
1039 /* Normal client usually send root access to MDT0 directly,
1040 * the root FID on non-MDT0 will only be used by echo client. */
1041 mdd->mdd_root_fid = fid;
1044 rc = orph_index_init(env, mdd);
1048 rc = mdd_changelog_init(env, mdd);
1050 CERROR("%s: failed to initialize changelog: rc = %d\n",
1051 mdd2obd_dev(mdd)->obd_name, rc);
1055 rc = mdd_hsm_actions_llog_init(env, mdd);
1057 GOTO(out_changelog, rc);
1059 rc = lfsck_register(env, mdd->mdd_bottom, mdd->mdd_child,
1060 mdd2obd_dev(mdd), mdd_lfsck_out_notify,
1063 CERROR("%s: failed to initialize lfsck: rc = %d\n",
1064 mdd2obd_dev(mdd)->obd_name, rc);
1069 mdd_hsm_actions_llog_fini(env, mdd);
1071 mdd_changelog_fini(env, mdd);
1073 orph_index_fini(env, mdd);
1075 if (mdd_seq_site(mdd)->ss_node_id == 0)
1076 mdd_dot_lustre_cleanup(env, mdd);
1078 local_oid_storage_fini(env, mdd->mdd_los);
1079 mdd->mdd_los = NULL;
1084 const struct lu_device_operations mdd_lu_ops = {
1085 .ldo_object_alloc = mdd_object_alloc,
1086 .ldo_process_config = mdd_process_config,
1087 .ldo_recovery_complete = mdd_recovery_complete,
1088 .ldo_prepare = mdd_prepare,
1091 static int mdd_root_get(const struct lu_env *env,
1092 struct md_device *m, struct lu_fid *f)
1094 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
1097 *f = mdd->mdd_root_fid;
1102 * No permission check is needed.
1104 static int mdd_statfs(const struct lu_env *env, struct md_device *m,
1105 struct obd_statfs *sfs)
1107 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
1112 rc = mdd_child_ops(mdd)->dt_statfs(env, mdd->mdd_child, sfs);
1114 sfs->os_namelen = min_t(__u32, sfs->os_namelen, NAME_MAX);
1119 static int mdd_maxeasize_get(const struct lu_env *env, struct md_device *m,
1122 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
1125 *easize = mdd->mdd_dt_conf.ddp_max_ea_size;
1130 static int mdd_llog_ctxt_get(const struct lu_env *env, struct md_device *m,
1133 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
1135 *h = llog_group_get_ctxt(&mdd2obd_dev(mdd)->obd_olg, idx);
1136 return (*h == NULL ? -ENOENT : 0);
1139 static struct lu_device *mdd_device_free(const struct lu_env *env,
1140 struct lu_device *lu)
1142 struct mdd_device *m = lu2mdd_dev(lu);
1145 LASSERT(atomic_read(&lu->ld_ref) == 0);
1146 md_device_fini(&m->mdd_md_dev);
1151 static struct lu_device *mdd_device_alloc(const struct lu_env *env,
1152 struct lu_device_type *t,
1153 struct lustre_cfg *lcfg)
1155 struct lu_device *l;
1156 struct mdd_device *m;
1160 l = ERR_PTR(-ENOMEM);
1165 md_device_init(&m->mdd_md_dev, t);
1166 rc = mdd_init0(env, m, t, lcfg);
1168 mdd_device_free(env, l);
1177 * we use exports to track all mdd users
1179 static int mdd_obd_connect(const struct lu_env *env, struct obd_export **exp,
1180 struct obd_device *obd, struct obd_uuid *cluuid,
1181 struct obd_connect_data *data, void *localdata)
1183 struct mdd_device *mdd = lu2mdd_dev(obd->obd_lu_dev);
1184 struct lustre_handle conn;
1188 CDEBUG(D_CONFIG, "connect #%d\n", mdd->mdd_connects);
1190 rc = class_connect(&conn, obd, cluuid);
1194 *exp = class_conn2export(&conn);
1196 /* Why should there ever be more than 1 connect? */
1197 LASSERT(mdd->mdd_connects == 0);
1198 mdd->mdd_connects++;
1204 * once last export (we don't count self-export) disappeared
1205 * mdd can be released
1207 static int mdd_obd_disconnect(struct obd_export *exp)
1209 struct obd_device *obd = exp->exp_obd;
1210 struct mdd_device *mdd = lu2mdd_dev(obd->obd_lu_dev);
1211 int rc, release = 0;
1214 mdd->mdd_connects--;
1215 if (mdd->mdd_connects == 0)
1218 rc = class_disconnect(exp);
1220 if (rc == 0 && release)
1221 class_manual_cleanup(obd);
1225 static int mdd_obd_get_info(const struct lu_env *env, struct obd_export *exp,
1226 __u32 keylen, void *key, __u32 *vallen, void *val)
1230 if (KEY_IS(KEY_OSP_CONNECTED)) {
1231 struct obd_device *obd = exp->exp_obd;
1232 struct mdd_device *mdd;
1234 if (!obd->obd_set_up || obd->obd_stopping)
1237 mdd = lu2mdd_dev(obd->obd_lu_dev);
1239 rc = obd_get_info(env, mdd->mdd_child_exp, keylen, key, vallen,
1247 static int mdd_obd_set_info_async(const struct lu_env *env,
1248 struct obd_export *exp,
1249 __u32 keylen, void *key,
1250 __u32 vallen, void *val,
1251 struct ptlrpc_request_set *set)
1253 struct obd_device *obd = exp->exp_obd;
1254 struct mdd_device *mdd;
1257 if (!obd->obd_set_up || obd->obd_stopping)
1260 mdd = lu2mdd_dev(obd->obd_lu_dev);
1262 rc = obd_set_info_async(env, mdd->mdd_child_exp, keylen, key,
1267 static struct obd_ops mdd_obd_device_ops = {
1268 .o_owner = THIS_MODULE,
1269 .o_connect = mdd_obd_connect,
1270 .o_disconnect = mdd_obd_disconnect,
1271 .o_get_info = mdd_obd_get_info,
1272 .o_set_info_async = mdd_obd_set_info_async,
1275 static int mdd_changelog_user_register(const struct lu_env *env,
1276 struct mdd_device *mdd, int *id)
1278 struct llog_ctxt *ctxt;
1279 struct llog_changelog_user_rec *rec;
1283 ctxt = llog_get_context(mdd2obd_dev(mdd),
1284 LLOG_CHANGELOG_USER_ORIG_CTXT);
1290 llog_ctxt_put(ctxt);
1294 /* Assume we want it on since somebody registered */
1295 rc = mdd_changelog_on(env, mdd);
1299 rec->cur_hdr.lrh_len = sizeof(*rec);
1300 rec->cur_hdr.lrh_type = CHANGELOG_USER_REC;
1301 spin_lock(&mdd->mdd_cl.mc_user_lock);
1302 if (mdd->mdd_cl.mc_lastuser == (unsigned int)(-1)) {
1303 spin_unlock(&mdd->mdd_cl.mc_user_lock);
1304 CERROR("Maximum number of changelog users exceeded!\n");
1305 GOTO(out, rc = -EOVERFLOW);
1307 *id = rec->cur_id = ++mdd->mdd_cl.mc_lastuser;
1308 rec->cur_endrec = mdd->mdd_cl.mc_index;
1309 spin_unlock(&mdd->mdd_cl.mc_user_lock);
1311 rc = llog_cat_add(env, ctxt->loc_handle, &rec->cur_hdr, NULL);
1313 CDEBUG(D_IOCTL, "Registered changelog user %d\n", *id);
1316 llog_ctxt_put(ctxt);
1320 struct mdd_changelog_user_data {
1321 __u64 mcud_endrec; /**< purge record for this user */
1322 __u64 mcud_minrec; /**< lowest changelog recno still referenced */
1324 __u32 mcud_minid; /**< user id with lowest rec reference */
1325 __u32 mcud_usercount;
1326 unsigned int mcud_found:1;
1328 #define MCUD_UNREGISTER -1LL
1331 * 1. Find the smallest record everyone is willing to purge
1332 * 2. Update the last purgeable record for this user
1334 static int mdd_changelog_user_purge_cb(const struct lu_env *env,
1335 struct llog_handle *llh,
1336 struct llog_rec_hdr *hdr, void *data)
1338 struct llog_changelog_user_rec *rec;
1339 struct mdd_changelog_user_data *mcud = data;
1344 LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
1346 rec = (struct llog_changelog_user_rec *)hdr;
1348 mcud->mcud_usercount++;
1350 /* If we have a new endrec for this id, use it for the following
1351 min check instead of its old value */
1352 if (rec->cur_id == mcud->mcud_id)
1353 rec->cur_endrec = max(rec->cur_endrec, mcud->mcud_endrec);
1355 /* Track the minimum referenced record */
1356 if (mcud->mcud_minid == 0 || mcud->mcud_minrec > rec->cur_endrec) {
1357 mcud->mcud_minid = rec->cur_id;
1358 mcud->mcud_minrec = rec->cur_endrec;
1361 if (rec->cur_id != mcud->mcud_id)
1364 /* Update this user's record */
1365 mcud->mcud_found = 1;
1367 /* Special case: unregister this user */
1368 if (mcud->mcud_endrec == MCUD_UNREGISTER) {
1369 struct llog_cookie cookie;
1371 cookie.lgc_lgl = llh->lgh_id;
1372 cookie.lgc_index = hdr->lrh_index;
1374 rc = llog_cat_cancel_records(env, llh->u.phd.phd_cat_handle,
1377 mcud->mcud_usercount--;
1382 /* Update the endrec */
1383 CDEBUG(D_IOCTL, "Rewriting changelog user %d endrec to "LPU64"\n",
1384 mcud->mcud_id, rec->cur_endrec);
1386 rc = llog_write(env, llh, hdr, hdr->lrh_index);
1391 static int mdd_changelog_user_purge(const struct lu_env *env,
1392 struct mdd_device *mdd, int id,
1395 struct mdd_changelog_user_data data;
1396 struct llog_ctxt *ctxt;
1400 CDEBUG(D_IOCTL, "Purge request: id=%d, endrec=%lld\n", id, endrec);
1403 data.mcud_minid = 0;
1404 data.mcud_minrec = 0;
1405 data.mcud_usercount = 0;
1406 data.mcud_endrec = endrec;
1407 spin_lock(&mdd->mdd_cl.mc_lock);
1408 endrec = mdd->mdd_cl.mc_index;
1409 spin_unlock(&mdd->mdd_cl.mc_lock);
1410 if ((data.mcud_endrec == 0) ||
1411 ((data.mcud_endrec > endrec) &&
1412 (data.mcud_endrec != MCUD_UNREGISTER)))
1413 data.mcud_endrec = endrec;
1415 ctxt = llog_get_context(mdd2obd_dev(mdd),
1416 LLOG_CHANGELOG_USER_ORIG_CTXT);
1420 LASSERT(ctxt->loc_handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT);
1422 rc = llog_cat_process(env, ctxt->loc_handle,
1423 mdd_changelog_user_purge_cb, (void *)&data,
1425 if ((rc >= 0) && (data.mcud_minrec > 0)) {
1426 CDEBUG(D_IOCTL, "Purging changelog entries up to "LPD64
1427 ", referenced by "CHANGELOG_USER_PREFIX"%d\n",
1428 data.mcud_minrec, data.mcud_minid);
1429 rc = mdd_changelog_llog_cancel(env, mdd, data.mcud_minrec);
1431 CWARN("Could not determine changelog records to purge; rc=%d\n",
1435 llog_ctxt_put(ctxt);
1437 if (!data.mcud_found) {
1438 CWARN("No entry for user %d. Last changelog reference is "
1439 LPD64" by changelog user %d\n", data.mcud_id,
1440 data.mcud_minrec, data.mcud_minid);
1444 if (!rc && data.mcud_usercount == 0)
1445 /* No more users; turn changelogs off */
1446 rc = mdd_changelog_off(env, mdd);
1452 * May be called remotely from mdt_iocontrol_handle or locally from
1453 * mdt_iocontrol. Data may be freeform - remote handling doesn't enforce
1454 * an obd_ioctl_data format (but local ioctl handler does).
1456 * \param len - data len
1457 * \param karg - ioctl data, in kernel space
1459 static int mdd_iocontrol(const struct lu_env *env, struct md_device *m,
1460 unsigned int cmd, int len, void *karg)
1462 struct mdd_device *mdd;
1463 struct obd_ioctl_data *data = karg;
1467 mdd = lu2mdd_dev(&m->md_lu_dev);
1469 /* Doesn't use obd_ioctl_data */
1471 case OBD_IOC_CHANGELOG_CLEAR: {
1472 struct changelog_setinfo *cs = karg;
1473 rc = mdd_changelog_user_purge(env, mdd, cs->cs_id,
1477 case OBD_IOC_GET_MNTOPT: {
1478 mntopt_t *mntopts = (mntopt_t *)karg;
1479 *mntopts = mdd->mdd_dt_conf.ddp_mntopts;
1482 case OBD_IOC_START_LFSCK: {
1483 rc = lfsck_start(env, mdd->mdd_bottom,
1484 (struct lfsck_start_param *)karg);
1487 case OBD_IOC_STOP_LFSCK: {
1488 rc = lfsck_stop(env, mdd->mdd_bottom,
1489 (struct lfsck_stop *)karg);
1492 case OBD_IOC_QUERY_LFSCK: {
1493 rc = lfsck_query(env, mdd->mdd_bottom, NULL, NULL,
1494 (struct lfsck_query *)karg);
1499 /* Below ioctls use obd_ioctl_data */
1500 if (len != sizeof(*data)) {
1501 CERROR("Bad ioctl size %d\n", len);
1504 if (data->ioc_version != OBD_IOCTL_VERSION) {
1505 CERROR("Bad magic %x != %x\n", data->ioc_version,
1511 case OBD_IOC_CHANGELOG_REG:
1512 rc = mdd_changelog_user_register(env, mdd, &data->ioc_u32_1);
1514 case OBD_IOC_CHANGELOG_DEREG:
1515 rc = mdd_changelog_user_purge(env, mdd, data->ioc_u32_1,
1525 /* type constructor/destructor: mdd_type_init, mdd_type_fini */
1526 LU_TYPE_INIT_FINI(mdd, &mdd_thread_key);
1528 static const struct md_device_operations mdd_ops = {
1529 .mdo_statfs = mdd_statfs,
1530 .mdo_root_get = mdd_root_get,
1531 .mdo_llog_ctxt_get = mdd_llog_ctxt_get,
1532 .mdo_iocontrol = mdd_iocontrol,
1533 .mdo_maxeasize_get = mdd_maxeasize_get,
1536 static struct lu_device_type_operations mdd_device_type_ops = {
1537 .ldto_init = mdd_type_init,
1538 .ldto_fini = mdd_type_fini,
1540 .ldto_start = mdd_type_start,
1541 .ldto_stop = mdd_type_stop,
1543 .ldto_device_alloc = mdd_device_alloc,
1544 .ldto_device_free = mdd_device_free,
1546 .ldto_device_fini = mdd_device_fini
1549 static struct lu_device_type mdd_device_type = {
1550 .ldt_tags = LU_DEVICE_MD,
1551 .ldt_name = LUSTRE_MDD_NAME,
1552 .ldt_ops = &mdd_device_type_ops,
1553 .ldt_ctx_tags = LCT_MD_THREAD
1556 /* context key constructor: mdd_key_init */
1557 LU_KEY_INIT(mdd, struct mdd_thread_info);
1559 static void mdd_key_fini(const struct lu_context *ctx,
1560 struct lu_context_key *key, void *data)
1562 struct mdd_thread_info *info = data;
1564 lu_buf_free(&info->mti_big_buf);
1565 lu_buf_free(&info->mti_link_buf);
1570 /* context key: mdd_thread_key */
1571 LU_CONTEXT_KEY_DEFINE(mdd, LCT_MD_THREAD);
1573 int mdd_generic_thread_start(struct mdd_generic_thread *thread,
1574 int (*func)(void *), void *data, char *name)
1576 struct task_struct *task;
1578 LASSERT(thread->mgt_init == false);
1579 init_completion(&thread->mgt_started);
1580 init_completion(&thread->mgt_finished);
1581 thread->mgt_data = data;
1582 thread->mgt_abort = false;
1583 thread->mgt_init = true;
1585 task = kthread_run(func, thread, name);
1587 complete(&thread->mgt_finished);
1588 return PTR_ERR(task);
1590 wait_for_completion(&thread->mgt_started);
1594 void mdd_generic_thread_stop(struct mdd_generic_thread *thread)
1596 if (thread->mgt_init == true) {
1597 thread->mgt_abort = true;
1598 wait_for_completion(&thread->mgt_finished);
1602 static int __init mdd_init(void)
1606 rc = lu_kmem_init(mdd_caches);
1610 changelog_orig_logops = llog_osd_ops;
1611 changelog_orig_logops.lop_cancel = llog_changelog_cancel;
1612 changelog_orig_logops.lop_add = llog_cat_add_rec;
1613 changelog_orig_logops.lop_declare_add = llog_cat_declare_add_rec;
1615 hsm_actions_logops = llog_osd_ops;
1616 hsm_actions_logops.lop_add = llog_cat_add_rec;
1617 hsm_actions_logops.lop_declare_add = llog_cat_declare_add_rec;
1619 rc = class_register_type(&mdd_obd_device_ops, NULL, true, NULL,
1620 LUSTRE_MDD_NAME, &mdd_device_type);
1622 lu_kmem_fini(mdd_caches);
1626 static void __exit mdd_exit(void)
1628 class_unregister_type(LUSTRE_MDD_NAME);
1629 lu_kmem_fini(mdd_caches);
1632 MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
1633 MODULE_DESCRIPTION("Lustre Meta-data Device Driver ("LUSTRE_MDD_NAME")");
1634 MODULE_VERSION(LUSTRE_VERSION_STRING);
1635 MODULE_LICENSE("GPL");
1637 module_init(mdd_init);
1638 module_exit(mdd_exit);