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 dev = lustre_cfg_string(lcfg, 0);
131 mdd->mdd_md_dev.md_lu_dev.ld_obd = class_name2obd(dev);
132 if (mdd->mdd_md_dev.md_lu_dev.ld_obd == NULL)
134 mdd->mdd_md_dev.md_lu_dev.ld_ops = &mdd_lu_ops;
135 mdd->mdd_md_dev.md_ops = &mdd_ops;
137 rc = mdd_connect_to_next(env, mdd, lustre_cfg_string(lcfg, 3));
141 mdd->mdd_atime_diff = MAX_ATIME_DIFF;
142 /* sync permission changes */
143 mdd->mdd_sync_permission = 1;
145 dt_conf_get(env, mdd->mdd_child, &mdd->mdd_dt_conf);
147 /* we are using service name but not mdd obd name
148 * for compatibility reasons.
149 * It is passed from MDT in lustre_cfg[2] buffer */
150 rc = mdd_procfs_init(mdd, lustre_cfg_string(lcfg, 2));
152 obd_disconnect(mdd->mdd_child_exp);
157 static struct lu_device *mdd_device_fini(const struct lu_env *env,
160 struct mdd_device *mdd = lu2mdd_dev(d);
163 lu_dev_del_linkage(d->ld_site, d);
165 mdd_procfs_fini(mdd);
169 static int changelog_init_cb(const struct lu_env *env, struct llog_handle *llh,
170 struct llog_rec_hdr *hdr, void *data)
172 struct mdd_device *mdd = (struct mdd_device *)data;
173 struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
175 LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
176 LASSERT(rec->cr_hdr.lrh_type == CHANGELOG_REC);
179 "seeing record at index %d/%d/"LPU64" t=%x %.*s in log"
180 DOSTID"\n", hdr->lrh_index, rec->cr_hdr.lrh_index,
181 rec->cr.cr_index, rec->cr.cr_type, rec->cr.cr_namelen,
182 changelog_rec_name(&rec->cr), POSTID(&llh->lgh_id.lgl_oi));
184 mdd->mdd_cl.mc_index = rec->cr.cr_index;
185 return LLOG_PROC_BREAK;
188 static int changelog_user_init_cb(const struct lu_env *env,
189 struct llog_handle *llh,
190 struct llog_rec_hdr *hdr, void *data)
192 struct mdd_device *mdd = (struct mdd_device *)data;
193 struct llog_changelog_user_rec *rec =
194 (struct llog_changelog_user_rec *)hdr;
196 LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
197 LASSERT(rec->cur_hdr.lrh_type == CHANGELOG_USER_REC);
199 CDEBUG(D_INFO, "seeing user at index %d/%d id=%d endrec="LPU64
200 " in log "DOSTID"\n", hdr->lrh_index, rec->cur_hdr.lrh_index,
201 rec->cur_id, rec->cur_endrec, POSTID(&llh->lgh_id.lgl_oi));
203 spin_lock(&mdd->mdd_cl.mc_user_lock);
204 mdd->mdd_cl.mc_lastuser = rec->cur_id;
205 if (rec->cur_endrec > mdd->mdd_cl.mc_index)
206 mdd->mdd_cl.mc_index = rec->cur_endrec;
207 spin_unlock(&mdd->mdd_cl.mc_user_lock);
209 return LLOG_PROC_BREAK;
212 static int llog_changelog_cancel_cb(const struct lu_env *env,
213 struct llog_handle *llh,
214 struct llog_rec_hdr *hdr, void *data)
216 struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
217 struct llog_cookie cookie;
218 long long endrec = *(long long *)data;
223 /* This is always a (sub)log, not the catalog */
224 LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
226 if (rec->cr.cr_index > endrec)
227 /* records are in order, so we're done */
228 RETURN(LLOG_PROC_BREAK);
230 cookie.lgc_lgl = llh->lgh_id;
231 cookie.lgc_index = hdr->lrh_index;
233 /* cancel them one at a time. I suppose we could store up the cookies
234 * and cancel them all at once; probably more efficient, but this is
235 * done as a user call, so who cares... */
236 rc = llog_cat_cancel_records(env, llh->u.phd.phd_cat_handle, 1,
238 RETURN(rc < 0 ? rc : 0);
241 static int llog_changelog_cancel(const struct lu_env *env,
242 struct llog_ctxt *ctxt,
243 struct llog_cookie *cookies, int flags)
245 struct llog_handle *cathandle = ctxt->loc_handle;
250 /* This should only be called with the catalog handle */
251 LASSERT(cathandle->lgh_hdr->llh_flags & LLOG_F_IS_CAT);
253 rc = llog_cat_process(env, cathandle, llog_changelog_cancel_cb,
254 (void *)cookies, 0, 0);
256 /* 0 or 1 means we're done */
259 CERROR("%s: cancel idx %u of catalog "DOSTID" rc=%d\n",
260 ctxt->loc_obd->obd_name, cathandle->lgh_last_idx,
261 POSTID(&cathandle->lgh_id.lgl_oi), rc);
266 static struct llog_operations changelog_orig_logops;
269 mdd_changelog_write_header(const struct lu_env *env, struct mdd_device *mdd,
273 mdd_changelog_on(const struct lu_env *env, struct mdd_device *mdd)
277 if ((mdd->mdd_cl.mc_flags & CLM_ON) != 0)
280 LCONSOLE_INFO("%s: changelog on\n", mdd2obd_dev(mdd)->obd_name);
281 if (mdd->mdd_cl.mc_flags & CLM_ERR) {
282 CERROR("Changelogs cannot be enabled due to error "
283 "condition (see %s log).\n",
284 mdd2obd_dev(mdd)->obd_name);
287 spin_lock(&mdd->mdd_cl.mc_lock);
288 mdd->mdd_cl.mc_flags |= CLM_ON;
289 spin_unlock(&mdd->mdd_cl.mc_lock);
290 rc = mdd_changelog_write_header(env, mdd, CLM_START);
296 mdd_changelog_off(const struct lu_env *env, struct mdd_device *mdd)
300 if ((mdd->mdd_cl.mc_flags & CLM_ON) != CLM_ON)
303 LCONSOLE_INFO("%s: changelog off\n", mdd2obd_dev(mdd)->obd_name);
304 rc = mdd_changelog_write_header(env, mdd, CLM_FINI);
305 spin_lock(&mdd->mdd_cl.mc_lock);
306 mdd->mdd_cl.mc_flags &= ~CLM_ON;
307 spin_unlock(&mdd->mdd_cl.mc_lock);
312 static int mdd_changelog_llog_init(const struct lu_env *env,
313 struct mdd_device *mdd)
315 struct obd_device *obd = mdd2obd_dev(mdd);
316 struct llog_ctxt *ctxt = NULL, *uctxt = NULL;
321 /* LU-2844 mdd setup failure should not cause umount oops */
322 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_CHANGELOG_INIT))
325 OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
326 obd->obd_lvfs_ctxt.dt = mdd->mdd_bottom;
327 rc = llog_setup(env, obd, &obd->obd_olg, LLOG_CHANGELOG_ORIG_CTXT,
328 obd, &changelog_orig_logops);
330 CERROR("%s: changelog llog setup failed: rc = %d\n",
335 ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
338 rc = llog_open_create(env, ctxt, &ctxt->loc_handle, NULL,
341 GOTO(out_cleanup, rc);
343 rc = llog_cat_init_and_process(env, ctxt->loc_handle);
347 rc = llog_cat_reverse_process(env, ctxt->loc_handle,
348 changelog_init_cb, mdd);
351 CERROR("%s: changelog init failed: rc = %d\n", obd->obd_name,
356 CDEBUG(D_IOCTL, "changelog starting index="LPU64"\n",
357 mdd->mdd_cl.mc_index);
359 /* setup user changelog */
360 rc = llog_setup(env, obd, &obd->obd_olg, LLOG_CHANGELOG_USER_ORIG_CTXT,
361 obd, &changelog_orig_logops);
363 CERROR("%s: changelog users llog setup failed: rc = %d\n",
368 uctxt = llog_get_context(obd, LLOG_CHANGELOG_USER_ORIG_CTXT);
371 rc = llog_open_create(env, uctxt, &uctxt->loc_handle, NULL,
374 GOTO(out_ucleanup, rc);
376 uctxt->loc_handle->lgh_logops->lop_add = llog_cat_add_rec;
377 uctxt->loc_handle->lgh_logops->lop_declare_add = llog_cat_declare_add_rec;
379 rc = llog_cat_init_and_process(env, uctxt->loc_handle);
381 GOTO(out_uclose, rc);
383 rc = llog_cat_reverse_process(env, uctxt->loc_handle,
384 changelog_user_init_cb, mdd);
386 CERROR("%s: changelog user init failed: rc = %d\n",
388 GOTO(out_uclose, rc);
391 /* If we have registered users, assume we want changelogs on */
392 if (mdd->mdd_cl.mc_lastuser > 0) {
393 rc = mdd_changelog_on(env, mdd);
395 GOTO(out_uclose, rc);
398 llog_ctxt_put(uctxt);
401 llog_cat_close(env, uctxt->loc_handle);
403 llog_cleanup(env, uctxt);
405 llog_cat_close(env, ctxt->loc_handle);
407 llog_cleanup(env, ctxt);
411 static int mdd_changelog_init(const struct lu_env *env, struct mdd_device *mdd)
413 struct obd_device *obd = mdd2obd_dev(mdd);
416 mdd->mdd_cl.mc_index = 0;
417 spin_lock_init(&mdd->mdd_cl.mc_lock);
418 mdd->mdd_cl.mc_starttime = cfs_time_current_64();
419 mdd->mdd_cl.mc_flags = 0; /* off by default */
420 mdd->mdd_cl.mc_mask = CHANGELOG_DEFMASK;
421 spin_lock_init(&mdd->mdd_cl.mc_user_lock);
422 mdd->mdd_cl.mc_lastuser = 0;
424 rc = mdd_changelog_llog_init(env, mdd);
426 CERROR("%s: changelog setup during init failed: rc = %d\n",
428 mdd->mdd_cl.mc_flags |= CLM_ERR;
434 static void mdd_changelog_fini(const struct lu_env *env,
435 struct mdd_device *mdd)
437 struct obd_device *obd = mdd2obd_dev(mdd);
438 struct llog_ctxt *ctxt;
440 mdd->mdd_cl.mc_flags = 0;
442 ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
444 llog_cat_close(env, ctxt->loc_handle);
445 llog_cleanup(env, ctxt);
447 ctxt = llog_get_context(obd, LLOG_CHANGELOG_USER_ORIG_CTXT);
449 llog_cat_close(env, ctxt->loc_handle);
450 llog_cleanup(env, ctxt);
454 /** Remove entries with indicies up to and including \a endrec from the
461 mdd_changelog_llog_cancel(const struct lu_env *env, struct mdd_device *mdd,
464 struct obd_device *obd = mdd2obd_dev(mdd);
465 struct llog_ctxt *ctxt;
466 long long unsigned cur;
469 ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
473 spin_lock(&mdd->mdd_cl.mc_lock);
474 cur = (long long)mdd->mdd_cl.mc_index;
475 spin_unlock(&mdd->mdd_cl.mc_lock);
479 /* purge to "0" is shorthand for everything */
483 /* If purging all records, write a header entry so we don't have an
484 empty catalog and we're sure to have a valid starting index next
485 time. In case of crash, we just restart with old log so we're
488 /* XXX: transaction is started by llog itself */
489 rc = mdd_changelog_write_header(env, mdd, CLM_PURGE);
494 /* Some records were purged, so reset repeat-access time (so we
495 record new mtime update records, so users can see a file has been
496 changed since the last purge) */
497 mdd->mdd_cl.mc_starttime = cfs_time_current_64();
499 rc = llog_cancel(env, ctxt, (struct llog_cookie *)&endrec, 0);
505 /** Add a CL_MARK record to the changelog
507 * \param markerflags - CLM_*
510 int mdd_changelog_write_header(const struct lu_env *env,
511 struct mdd_device *mdd, int markerflags)
513 struct obd_device *obd = mdd2obd_dev(mdd);
514 struct llog_changelog_rec *rec;
516 struct llog_ctxt *ctxt;
518 int len = strlen(obd->obd_name);
523 if (mdd->mdd_cl.mc_mask & (1 << CL_MARK)) {
524 mdd->mdd_cl.mc_starttime = cfs_time_current_64();
528 reclen = llog_data_len(sizeof(*rec) + len);
529 buf = lu_buf_check_and_alloc(&mdd_env_info(env)->mti_big_buf, reclen);
530 if (buf->lb_buf == NULL)
534 rec->cr.cr_flags = CLF_VERSION;
535 rec->cr.cr_type = CL_MARK;
536 rec->cr.cr_namelen = len;
537 memcpy(changelog_rec_name(&rec->cr), obd->obd_name, rec->cr.cr_namelen);
538 /* Status and action flags */
539 rec->cr.cr_markerflags = mdd->mdd_cl.mc_flags | markerflags;
540 rec->cr_hdr.lrh_len = llog_data_len(changelog_rec_size(&rec->cr) +
542 rec->cr_hdr.lrh_type = CHANGELOG_REC;
543 rec->cr.cr_time = cl_time();
544 spin_lock(&mdd->mdd_cl.mc_lock);
545 rec->cr.cr_index = ++mdd->mdd_cl.mc_index;
546 spin_unlock(&mdd->mdd_cl.mc_lock);
548 ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
551 rc = llog_cat_add(env, ctxt->loc_handle, &rec->cr_hdr, NULL);
556 /* assume on or off event; reset repeat-access time */
557 mdd->mdd_cl.mc_starttime = cfs_time_current_64();
562 * Lookup method for "fid" object. Only filenames with correct SEQ:OID format
563 * are valid. We also check if object with passed fid exists or not.
565 static int obf_lookup(const struct lu_env *env, struct md_object *p,
566 const struct lu_name *lname, struct lu_fid *f,
567 struct md_op_spec *spec)
569 char *name = (char *)lname->ln_name;
570 struct mdd_device *mdd = mdo2mdd(p);
571 struct mdd_object *child;
577 sscanf(name, SFID, RFID(f));
578 if (!fid_is_sane(f)) {
579 CWARN("%s: Trying to lookup invalid FID [%s] in %s/%s, FID "
580 "format should be "DFID"\n", mdd2obd_dev(mdd)->obd_name,
581 lname->ln_name, dot_lustre_name, mdd_obf_dir_name,
582 (__u64)FID_SEQ_NORMAL, 1, 0);
583 GOTO(out, rc = -EINVAL);
586 if (!fid_is_norm(f) && !fid_is_igif(f) && !fid_is_root(f) &&
587 !fid_seq_is_dot(f->f_seq)) {
588 CWARN("%s: Trying to lookup invalid FID "DFID" in %s/%s, "
589 "sequence should be >= "LPX64" or within ["LPX64","
590 ""LPX64"].\n", mdd2obd_dev(mdd)->obd_name, PFID(f),
591 dot_lustre_name, mdd_obf_dir_name, (__u64)FID_SEQ_NORMAL,
592 (__u64)FID_SEQ_IGIF, (__u64)FID_SEQ_IGIF_MAX);
593 GOTO(out, rc = -EINVAL);
596 /* Check if object with this fid exists */
597 child = mdd_object_find(env, mdd, f);
599 GOTO(out, rc = PTR_ERR(child));
601 if (mdd_object_exists(child) == 0)
604 mdd_object_put(env, child);
610 static int mdd_dummy_create(const struct lu_env *env,
611 struct md_object *pobj,
612 const struct lu_name *lname,
613 struct md_object *child,
614 struct md_op_spec *spec,
620 static int mdd_dummy_rename(const struct lu_env *env,
621 struct md_object *src_pobj,
622 struct md_object *tgt_pobj,
623 const struct lu_fid *lf,
624 const struct lu_name *lsname,
625 struct md_object *tobj,
626 const struct lu_name *ltname,
632 static int mdd_dummy_link(const struct lu_env *env,
633 struct md_object *tgt_obj,
634 struct md_object *src_obj,
635 const struct lu_name *lname,
641 static int mdd_dummy_unlink(const struct lu_env *env,
642 struct md_object *pobj,
643 struct md_object *cobj,
644 const struct lu_name *lname,
651 static struct md_dir_operations mdd_obf_dir_ops = {
652 .mdo_lookup = obf_lookup,
653 .mdo_create = mdd_dummy_create,
654 .mdo_rename = mdd_dummy_rename,
655 .mdo_link = mdd_dummy_link,
656 .mdo_unlink = mdd_dummy_unlink
659 static struct md_dir_operations mdd_lpf_dir_ops = {
660 .mdo_lookup = mdd_lookup,
661 .mdo_create = mdd_dummy_create,
662 .mdo_rename = mdd_dummy_rename,
663 .mdo_link = mdd_dummy_link,
664 .mdo_unlink = mdd_dummy_unlink
667 static struct md_object *mdo_locate(const struct lu_env *env,
668 struct md_device *md,
669 const struct lu_fid *fid)
671 struct lu_object *obj;
672 struct md_object *mdo;
674 obj = lu_object_find(env, &md->md_lu_dev, fid, NULL);
676 obj = lu_object_locate(obj->lo_header, md->md_lu_dev.ld_type);
677 LASSERT(obj != NULL);
680 mdo = ERR_PTR(PTR_ERR(obj));
685 static int mdd_lpf_setup(const struct lu_env *env, struct mdd_device *m)
687 struct md_object *mdo;
688 struct mdd_object *mdd_lpf;
689 struct lu_fid fid = LU_LPF_FID;
693 rc = mdd_local_file_create(env, m, mdd_object_fid(m->mdd_dot_lustre),
694 mdd_lpf_dir_name, S_IFDIR | S_IRUSR | S_IXUSR,
699 mdo = mdo_locate(env, &m->mdd_md_dev, &fid);
701 RETURN(PTR_ERR(mdo));
703 LASSERT(lu_object_exists(&mdo->mo_lu));
705 mdd_lpf = md2mdd_obj(mdo);
706 mdd_lpf->mod_obj.mo_dir_ops = &mdd_lpf_dir_ops;
707 m->mdd_dot_lustre_objs.mdd_lpf = mdd_lpf;
713 * Create special in-memory "fid" object for open-by-fid.
715 static int mdd_obf_setup(const struct lu_env *env, struct mdd_device *m)
717 struct md_object *mdo;
718 struct mdd_object *mdd_obf;
719 struct lu_fid fid = LU_OBF_FID;
722 rc = mdd_local_file_create(env, m, mdd_object_fid(m->mdd_dot_lustre),
723 mdd_obf_dir_name, S_IFDIR | S_IXUSR, &fid);
727 mdo = mdo_locate(env, &m->mdd_md_dev, &fid);
729 RETURN(PTR_ERR(mdo));
731 LASSERT(lu_object_exists(&mdo->mo_lu));
733 mdd_obf = md2mdd_obj(mdo);
734 mdd_obf->mod_obj.mo_dir_ops = &mdd_obf_dir_ops;
735 m->mdd_dot_lustre_objs.mdd_obf = mdd_obf;
740 static void mdd_dot_lustre_cleanup(const struct lu_env *env,
741 struct mdd_device *m)
743 if (m->mdd_dot_lustre_objs.mdd_lpf != NULL) {
744 mdd_object_put(env, m->mdd_dot_lustre_objs.mdd_lpf);
745 m->mdd_dot_lustre_objs.mdd_lpf = NULL;
747 if (m->mdd_dot_lustre_objs.mdd_obf != NULL) {
748 mdd_object_put(env, m->mdd_dot_lustre_objs.mdd_obf);
749 m->mdd_dot_lustre_objs.mdd_obf = NULL;
751 if (m->mdd_dot_lustre != NULL) {
752 mdd_object_put(env, m->mdd_dot_lustre);
753 m->mdd_dot_lustre = NULL;
757 /** Setup ".lustre" directory object */
758 static int mdd_dot_lustre_setup(const struct lu_env *env, struct mdd_device *m)
760 struct md_object *mdo;
765 /* Create ".lustre" directory in ROOT. */
766 fid = LU_DOT_LUSTRE_FID;
767 rc = mdd_local_file_create(env, m, &m->mdd_root_fid,
769 S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO,
773 mdo = mdo_locate(env, &m->mdd_md_dev, &fid);
775 RETURN(PTR_ERR(mdo));
776 LASSERT(lu_object_exists(&mdo->mo_lu));
778 m->mdd_dot_lustre = md2mdd_obj(mdo);
780 rc = mdd_obf_setup(env, m);
782 CERROR("%s: error initializing \"fid\" object: rc = %d.\n",
783 mdd2obd_dev(m)->obd_name, rc);
787 rc = mdd_lpf_setup(env, m);
789 CERROR("%s: error initializing \"lost+found\": rc = %d.\n",
790 mdd2obd_dev(m)->obd_name, rc);
797 mdd_dot_lustre_cleanup(env, m);
803 static struct llog_operations hsm_actions_logops;
806 * set llog methods and create LLOG_AGENT_ORIG_CTXT llog
807 * object in obd_device
809 static int mdd_hsm_actions_llog_init(const struct lu_env *env,
810 struct mdd_device *m)
812 struct obd_device *obd = mdd2obd_dev(m);
813 struct llog_ctxt *ctxt = NULL;
817 OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
818 obd->obd_lvfs_ctxt.dt = m->mdd_bottom;
820 rc = llog_setup(env, obd, &obd->obd_olg, LLOG_AGENT_ORIG_CTXT,
821 obd, &hsm_actions_logops);
823 CERROR("%s: hsm actions llog setup failed: rc = %d\n",
828 ctxt = llog_get_context(obd, LLOG_AGENT_ORIG_CTXT);
831 rc = llog_open_create(env, ctxt, &ctxt->loc_handle, NULL,
834 CERROR("%s: hsm actions llog open_create failed: rc = %d\n",
836 GOTO(out_cleanup, rc);
839 rc = llog_cat_init_and_process(env, ctxt->loc_handle);
847 llog_cat_close(env, ctxt->loc_handle);
848 ctxt->loc_handle = NULL;
850 llog_cleanup(env, ctxt);
856 * cleanup the context created by llog_setup_named()
858 static int mdd_hsm_actions_llog_fini(const struct lu_env *env,
859 struct mdd_device *m)
861 struct obd_device *obd = mdd2obd_dev(m);
862 struct llog_ctxt *lctxt;
865 lctxt = llog_get_context(obd, LLOG_AGENT_ORIG_CTXT);
867 llog_cat_close(env, lctxt->loc_handle);
868 lctxt->loc_handle = NULL;
869 llog_cleanup(env, lctxt);
875 static void mdd_device_shutdown(const struct lu_env *env, struct mdd_device *m,
876 struct lustre_cfg *cfg)
878 mdd_generic_thread_stop(&m->mdd_orph_cleanup_thread);
879 lfsck_degister(env, m->mdd_bottom);
880 mdd_hsm_actions_llog_fini(env, m);
881 mdd_changelog_fini(env, m);
882 orph_index_fini(env, m);
883 mdd_dot_lustre_cleanup(env, m);
884 if (m->mdd_los != NULL) {
885 local_oid_storage_fini(env, m->mdd_los);
888 lu_site_purge(env, mdd2lu_dev(m)->ld_site, ~0);
890 if (m->mdd_child_exp)
891 obd_disconnect(m->mdd_child_exp);
894 static int mdd_process_config(const struct lu_env *env,
895 struct lu_device *d, struct lustre_cfg *cfg)
897 struct mdd_device *m = lu2mdd_dev(d);
898 struct dt_device *dt = m->mdd_child;
899 struct lu_device *next = &dt->dd_lu_dev;
903 switch (cfg->lcfg_command) {
905 struct obd_device *obd = mdd2obd_dev(m);
907 rc = class_process_proc_param(PARAM_MDD, obd->obd_vars, cfg, m);
908 if (rc > 0 || rc == -ENOSYS)
909 /* we don't understand; pass it on */
910 rc = next->ld_ops->ldo_process_config(env, next, cfg);
914 rc = next->ld_ops->ldo_process_config(env, next, cfg);
917 dt_conf_get(env, dt, &m->mdd_dt_conf);
920 rc = next->ld_ops->ldo_process_config(env, next, cfg);
921 lu_dev_del_linkage(d->ld_site, d);
922 mdd_device_shutdown(env, m, cfg);
925 rc = next->ld_ops->ldo_process_config(env, next, cfg);
932 static int mdd_recovery_complete(const struct lu_env *env,
935 struct mdd_device *mdd = lu2mdd_dev(d);
936 struct lu_device *next;
940 LASSERT(mdd != NULL);
941 next = &mdd->mdd_child->dd_lu_dev;
943 /* XXX: orphans handling. */
944 mdd_orphan_cleanup(env, mdd);
945 rc = next->ld_ops->ldo_recovery_complete(env, next);
950 int mdd_local_file_create(const struct lu_env *env, struct mdd_device *mdd,
951 const struct lu_fid *pfid, const char *name,
952 __u32 mode, struct lu_fid *fid)
954 struct dt_object *parent, *dto;
959 LASSERT(!fid_is_zero(pfid));
960 parent = dt_locate(env, mdd->mdd_bottom, pfid);
961 if (unlikely(IS_ERR(parent)))
962 RETURN(PTR_ERR(parent));
964 /* create local file/dir, if @fid is passed then try to use it */
965 if (fid_is_zero(fid))
966 dto = local_file_find_or_create(env, mdd->mdd_los, parent,
969 dto = local_file_find_or_create_with_fid(env, mdd->mdd_bottom,
973 GOTO(out_put, rc = PTR_ERR(dto));
974 *fid = *lu_object_fid(&dto->do_lu);
975 /* since stack is not fully set up the local_storage uses own stack
976 * and we should drop its object from cache */
977 lu_object_put_nocache(env, &dto->do_lu);
980 lu_object_put(env, &parent->do_lu);
984 static int mdd_lfsck_out_notify(const struct lu_env *env, void *data,
985 enum lfsck_events event)
990 static int mdd_prepare(const struct lu_env *env,
991 struct lu_device *pdev,
992 struct lu_device *cdev)
994 struct mdd_device *mdd = lu2mdd_dev(cdev);
995 struct lu_device *next = &mdd->mdd_child->dd_lu_dev;
1001 rc = next->ld_ops->ldo_prepare(env, cdev, next);
1005 /* Setup local dirs */
1006 fid.f_seq = FID_SEQ_LOCAL_NAME;
1009 rc = local_oid_storage_init(env, mdd->mdd_bottom, &fid,
1014 rc = dt_root_get(env, mdd->mdd_child, &mdd->mdd_local_root_fid);
1019 if (mdd_seq_site(mdd)->ss_node_id == 0) {
1020 rc = mdd_local_file_create(env, mdd, &mdd->mdd_local_root_fid,
1021 mdd_root_dir_name, S_IFDIR |
1022 S_IRUGO | S_IWUSR | S_IXUGO, &fid);
1024 CERROR("%s: create root fid failed: rc = %d\n",
1025 mdd2obd_dev(mdd)->obd_name, rc);
1029 mdd->mdd_root_fid = fid;
1030 rc = mdd_dot_lustre_setup(env, mdd);
1032 CERROR("%s: initializing .lustre failed: rc = %d\n",
1033 mdd2obd_dev(mdd)->obd_name, rc);
1037 /* Normal client usually send root access to MDT0 directly,
1038 * the root FID on non-MDT0 will only be used by echo client. */
1039 mdd->mdd_root_fid = fid;
1042 rc = orph_index_init(env, mdd);
1046 rc = mdd_changelog_init(env, mdd);
1048 CERROR("%s: failed to initialize changelog: rc = %d\n",
1049 mdd2obd_dev(mdd)->obd_name, rc);
1053 rc = mdd_hsm_actions_llog_init(env, mdd);
1055 GOTO(out_changelog, rc);
1057 rc = lfsck_register(env, mdd->mdd_bottom, mdd->mdd_child,
1058 mdd2obd_dev(mdd), mdd_lfsck_out_notify,
1061 CERROR("%s: failed to initialize lfsck: rc = %d\n",
1062 mdd2obd_dev(mdd)->obd_name, rc);
1067 mdd_hsm_actions_llog_fini(env, mdd);
1069 mdd_changelog_fini(env, mdd);
1071 orph_index_fini(env, mdd);
1073 if (mdd_seq_site(mdd)->ss_node_id == 0)
1074 mdd_dot_lustre_cleanup(env, mdd);
1076 local_oid_storage_fini(env, mdd->mdd_los);
1077 mdd->mdd_los = NULL;
1082 const struct lu_device_operations mdd_lu_ops = {
1083 .ldo_object_alloc = mdd_object_alloc,
1084 .ldo_process_config = mdd_process_config,
1085 .ldo_recovery_complete = mdd_recovery_complete,
1086 .ldo_prepare = mdd_prepare,
1089 static int mdd_root_get(const struct lu_env *env,
1090 struct md_device *m, struct lu_fid *f)
1092 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
1095 *f = mdd->mdd_root_fid;
1100 * No permission check is needed.
1102 static int mdd_statfs(const struct lu_env *env, struct md_device *m,
1103 struct obd_statfs *sfs)
1105 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
1110 rc = mdd_child_ops(mdd)->dt_statfs(env, mdd->mdd_child, sfs);
1112 sfs->os_namelen = min_t(__u32, sfs->os_namelen, NAME_MAX);
1117 static int mdd_maxeasize_get(const struct lu_env *env, struct md_device *m,
1120 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
1123 *easize = mdd->mdd_dt_conf.ddp_max_ea_size;
1128 static int mdd_llog_ctxt_get(const struct lu_env *env, struct md_device *m,
1131 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
1133 *h = llog_group_get_ctxt(&mdd2obd_dev(mdd)->obd_olg, idx);
1134 return (*h == NULL ? -ENOENT : 0);
1137 static struct lu_device *mdd_device_free(const struct lu_env *env,
1138 struct lu_device *lu)
1140 struct mdd_device *m = lu2mdd_dev(lu);
1143 LASSERT(atomic_read(&lu->ld_ref) == 0);
1144 md_device_fini(&m->mdd_md_dev);
1149 static struct lu_device *mdd_device_alloc(const struct lu_env *env,
1150 struct lu_device_type *t,
1151 struct lustre_cfg *lcfg)
1153 struct lu_device *l;
1154 struct mdd_device *m;
1158 l = ERR_PTR(-ENOMEM);
1163 md_device_init(&m->mdd_md_dev, t);
1164 rc = mdd_init0(env, m, t, lcfg);
1166 mdd_device_free(env, l);
1175 * we use exports to track all mdd users
1177 static int mdd_obd_connect(const struct lu_env *env, struct obd_export **exp,
1178 struct obd_device *obd, struct obd_uuid *cluuid,
1179 struct obd_connect_data *data, void *localdata)
1181 struct mdd_device *mdd = lu2mdd_dev(obd->obd_lu_dev);
1182 struct lustre_handle conn;
1186 CDEBUG(D_CONFIG, "connect #%d\n", mdd->mdd_connects);
1188 rc = class_connect(&conn, obd, cluuid);
1192 *exp = class_conn2export(&conn);
1194 /* Why should there ever be more than 1 connect? */
1195 LASSERT(mdd->mdd_connects == 0);
1196 mdd->mdd_connects++;
1202 * once last export (we don't count self-export) disappeared
1203 * mdd can be released
1205 static int mdd_obd_disconnect(struct obd_export *exp)
1207 struct obd_device *obd = exp->exp_obd;
1208 struct mdd_device *mdd = lu2mdd_dev(obd->obd_lu_dev);
1209 int rc, release = 0;
1212 mdd->mdd_connects--;
1213 if (mdd->mdd_connects == 0)
1216 rc = class_disconnect(exp);
1218 if (rc == 0 && release)
1219 class_manual_cleanup(obd);
1223 static int mdd_obd_get_info(const struct lu_env *env, struct obd_export *exp,
1224 __u32 keylen, void *key, __u32 *vallen, void *val)
1228 if (KEY_IS(KEY_OSP_CONNECTED)) {
1229 struct obd_device *obd = exp->exp_obd;
1230 struct mdd_device *mdd;
1232 if (!obd->obd_set_up || obd->obd_stopping)
1235 mdd = lu2mdd_dev(obd->obd_lu_dev);
1237 rc = obd_get_info(env, mdd->mdd_child_exp, keylen, key, vallen,
1245 static int mdd_obd_set_info_async(const struct lu_env *env,
1246 struct obd_export *exp,
1247 __u32 keylen, void *key,
1248 __u32 vallen, void *val,
1249 struct ptlrpc_request_set *set)
1251 struct obd_device *obd = exp->exp_obd;
1252 struct mdd_device *mdd;
1255 if (!obd->obd_set_up || obd->obd_stopping)
1258 mdd = lu2mdd_dev(obd->obd_lu_dev);
1260 rc = obd_set_info_async(env, mdd->mdd_child_exp, keylen, key,
1265 static struct obd_ops mdd_obd_device_ops = {
1266 .o_owner = THIS_MODULE,
1267 .o_connect = mdd_obd_connect,
1268 .o_disconnect = mdd_obd_disconnect,
1269 .o_get_info = mdd_obd_get_info,
1270 .o_set_info_async = mdd_obd_set_info_async,
1273 static int mdd_changelog_user_register(const struct lu_env *env,
1274 struct mdd_device *mdd, int *id)
1276 struct llog_ctxt *ctxt;
1277 struct llog_changelog_user_rec *rec;
1281 ctxt = llog_get_context(mdd2obd_dev(mdd),
1282 LLOG_CHANGELOG_USER_ORIG_CTXT);
1288 llog_ctxt_put(ctxt);
1292 /* Assume we want it on since somebody registered */
1293 rc = mdd_changelog_on(env, mdd);
1297 rec->cur_hdr.lrh_len = sizeof(*rec);
1298 rec->cur_hdr.lrh_type = CHANGELOG_USER_REC;
1299 spin_lock(&mdd->mdd_cl.mc_user_lock);
1300 if (mdd->mdd_cl.mc_lastuser == (unsigned int)(-1)) {
1301 spin_unlock(&mdd->mdd_cl.mc_user_lock);
1302 CERROR("Maximum number of changelog users exceeded!\n");
1303 GOTO(out, rc = -EOVERFLOW);
1305 *id = rec->cur_id = ++mdd->mdd_cl.mc_lastuser;
1306 rec->cur_endrec = mdd->mdd_cl.mc_index;
1307 spin_unlock(&mdd->mdd_cl.mc_user_lock);
1309 rc = llog_cat_add(env, ctxt->loc_handle, &rec->cur_hdr, NULL);
1311 CDEBUG(D_IOCTL, "Registered changelog user %d\n", *id);
1314 llog_ctxt_put(ctxt);
1318 struct mdd_changelog_user_data {
1319 __u64 mcud_endrec; /**< purge record for this user */
1320 __u64 mcud_minrec; /**< lowest changelog recno still referenced */
1322 __u32 mcud_minid; /**< user id with lowest rec reference */
1323 __u32 mcud_usercount;
1324 unsigned int mcud_found:1;
1326 #define MCUD_UNREGISTER -1LL
1329 * 1. Find the smallest record everyone is willing to purge
1330 * 2. Update the last purgeable record for this user
1332 static int mdd_changelog_user_purge_cb(const struct lu_env *env,
1333 struct llog_handle *llh,
1334 struct llog_rec_hdr *hdr, void *data)
1336 struct llog_changelog_user_rec *rec;
1337 struct mdd_changelog_user_data *mcud = data;
1342 LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
1344 rec = (struct llog_changelog_user_rec *)hdr;
1346 mcud->mcud_usercount++;
1348 /* If we have a new endrec for this id, use it for the following
1349 min check instead of its old value */
1350 if (rec->cur_id == mcud->mcud_id)
1351 rec->cur_endrec = max(rec->cur_endrec, mcud->mcud_endrec);
1353 /* Track the minimum referenced record */
1354 if (mcud->mcud_minid == 0 || mcud->mcud_minrec > rec->cur_endrec) {
1355 mcud->mcud_minid = rec->cur_id;
1356 mcud->mcud_minrec = rec->cur_endrec;
1359 if (rec->cur_id != mcud->mcud_id)
1362 /* Update this user's record */
1363 mcud->mcud_found = 1;
1365 /* Special case: unregister this user */
1366 if (mcud->mcud_endrec == MCUD_UNREGISTER) {
1367 struct llog_cookie cookie;
1369 cookie.lgc_lgl = llh->lgh_id;
1370 cookie.lgc_index = hdr->lrh_index;
1372 rc = llog_cat_cancel_records(env, llh->u.phd.phd_cat_handle,
1375 mcud->mcud_usercount--;
1380 /* Update the endrec */
1381 CDEBUG(D_IOCTL, "Rewriting changelog user %d endrec to "LPU64"\n",
1382 mcud->mcud_id, rec->cur_endrec);
1384 rc = llog_write(env, llh, hdr, hdr->lrh_index);
1389 static int mdd_changelog_user_purge(const struct lu_env *env,
1390 struct mdd_device *mdd, int id,
1393 struct mdd_changelog_user_data data;
1394 struct llog_ctxt *ctxt;
1398 CDEBUG(D_IOCTL, "Purge request: id=%d, endrec=%lld\n", id, endrec);
1401 data.mcud_minid = 0;
1402 data.mcud_minrec = 0;
1403 data.mcud_usercount = 0;
1404 data.mcud_endrec = endrec;
1405 spin_lock(&mdd->mdd_cl.mc_lock);
1406 endrec = mdd->mdd_cl.mc_index;
1407 spin_unlock(&mdd->mdd_cl.mc_lock);
1408 if ((data.mcud_endrec == 0) ||
1409 ((data.mcud_endrec > endrec) &&
1410 (data.mcud_endrec != MCUD_UNREGISTER)))
1411 data.mcud_endrec = endrec;
1413 ctxt = llog_get_context(mdd2obd_dev(mdd),
1414 LLOG_CHANGELOG_USER_ORIG_CTXT);
1418 LASSERT(ctxt->loc_handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT);
1420 rc = llog_cat_process(env, ctxt->loc_handle,
1421 mdd_changelog_user_purge_cb, (void *)&data,
1423 if ((rc >= 0) && (data.mcud_minrec > 0)) {
1424 CDEBUG(D_IOCTL, "Purging changelog entries up to "LPD64
1425 ", referenced by "CHANGELOG_USER_PREFIX"%d\n",
1426 data.mcud_minrec, data.mcud_minid);
1427 rc = mdd_changelog_llog_cancel(env, mdd, data.mcud_minrec);
1429 CWARN("Could not determine changelog records to purge; rc=%d\n",
1433 llog_ctxt_put(ctxt);
1435 if (!data.mcud_found) {
1436 CWARN("No entry for user %d. Last changelog reference is "
1437 LPD64" by changelog user %d\n", data.mcud_id,
1438 data.mcud_minrec, data.mcud_minid);
1442 if (!rc && data.mcud_usercount == 0)
1443 /* No more users; turn changelogs off */
1444 rc = mdd_changelog_off(env, mdd);
1450 * May be called remotely from mdt_iocontrol_handle or locally from
1451 * mdt_iocontrol. Data may be freeform - remote handling doesn't enforce
1452 * an obd_ioctl_data format (but local ioctl handler does).
1454 * \param len - data len
1455 * \param karg - ioctl data, in kernel space
1457 static int mdd_iocontrol(const struct lu_env *env, struct md_device *m,
1458 unsigned int cmd, int len, void *karg)
1460 struct mdd_device *mdd;
1461 struct obd_ioctl_data *data = karg;
1465 mdd = lu2mdd_dev(&m->md_lu_dev);
1467 /* Doesn't use obd_ioctl_data */
1469 case OBD_IOC_CHANGELOG_CLEAR: {
1470 struct changelog_setinfo *cs = karg;
1471 rc = mdd_changelog_user_purge(env, mdd, cs->cs_id,
1475 case OBD_IOC_GET_MNTOPT: {
1476 mntopt_t *mntopts = (mntopt_t *)karg;
1477 *mntopts = mdd->mdd_dt_conf.ddp_mntopts;
1480 case OBD_IOC_START_LFSCK: {
1481 rc = lfsck_start(env, mdd->mdd_bottom,
1482 (struct lfsck_start_param *)karg);
1485 case OBD_IOC_STOP_LFSCK: {
1486 rc = lfsck_stop(env, mdd->mdd_bottom,
1487 (struct lfsck_stop *)karg);
1492 /* Below ioctls use obd_ioctl_data */
1493 if (len != sizeof(*data)) {
1494 CERROR("Bad ioctl size %d\n", len);
1497 if (data->ioc_version != OBD_IOCTL_VERSION) {
1498 CERROR("Bad magic %x != %x\n", data->ioc_version,
1504 case OBD_IOC_CHANGELOG_REG:
1505 rc = mdd_changelog_user_register(env, mdd, &data->ioc_u32_1);
1507 case OBD_IOC_CHANGELOG_DEREG:
1508 rc = mdd_changelog_user_purge(env, mdd, data->ioc_u32_1,
1518 /* type constructor/destructor: mdd_type_init, mdd_type_fini */
1519 LU_TYPE_INIT_FINI(mdd, &mdd_thread_key);
1521 static const struct md_device_operations mdd_ops = {
1522 .mdo_statfs = mdd_statfs,
1523 .mdo_root_get = mdd_root_get,
1524 .mdo_llog_ctxt_get = mdd_llog_ctxt_get,
1525 .mdo_iocontrol = mdd_iocontrol,
1526 .mdo_maxeasize_get = mdd_maxeasize_get,
1529 static struct lu_device_type_operations mdd_device_type_ops = {
1530 .ldto_init = mdd_type_init,
1531 .ldto_fini = mdd_type_fini,
1533 .ldto_start = mdd_type_start,
1534 .ldto_stop = mdd_type_stop,
1536 .ldto_device_alloc = mdd_device_alloc,
1537 .ldto_device_free = mdd_device_free,
1539 .ldto_device_fini = mdd_device_fini
1542 static struct lu_device_type mdd_device_type = {
1543 .ldt_tags = LU_DEVICE_MD,
1544 .ldt_name = LUSTRE_MDD_NAME,
1545 .ldt_ops = &mdd_device_type_ops,
1546 .ldt_ctx_tags = LCT_MD_THREAD
1549 /* context key constructor: mdd_key_init */
1550 LU_KEY_INIT(mdd, struct mdd_thread_info);
1552 static void mdd_key_fini(const struct lu_context *ctx,
1553 struct lu_context_key *key, void *data)
1555 struct mdd_thread_info *info = data;
1557 lu_buf_free(&info->mti_big_buf);
1558 lu_buf_free(&info->mti_link_buf);
1563 /* context key: mdd_thread_key */
1564 LU_CONTEXT_KEY_DEFINE(mdd, LCT_MD_THREAD);
1566 int mdd_generic_thread_start(struct mdd_generic_thread *thread,
1567 int (*func)(void *), void *data, char *name)
1569 struct task_struct *task;
1571 LASSERT(thread->mgt_init == false);
1572 init_completion(&thread->mgt_started);
1573 init_completion(&thread->mgt_finished);
1574 thread->mgt_data = data;
1575 thread->mgt_abort = false;
1576 thread->mgt_init = true;
1578 task = kthread_run(func, thread, name);
1580 complete(&thread->mgt_finished);
1581 return PTR_ERR(task);
1583 wait_for_completion(&thread->mgt_started);
1587 void mdd_generic_thread_stop(struct mdd_generic_thread *thread)
1589 if (thread->mgt_init == true) {
1590 thread->mgt_abort = true;
1591 wait_for_completion(&thread->mgt_finished);
1595 static int __init mdd_init(void)
1599 rc = lu_kmem_init(mdd_caches);
1603 changelog_orig_logops = llog_osd_ops;
1604 changelog_orig_logops.lop_cancel = llog_changelog_cancel;
1605 changelog_orig_logops.lop_add = llog_cat_add_rec;
1606 changelog_orig_logops.lop_declare_add = llog_cat_declare_add_rec;
1608 hsm_actions_logops = llog_osd_ops;
1609 hsm_actions_logops.lop_add = llog_cat_add_rec;
1610 hsm_actions_logops.lop_declare_add = llog_cat_declare_add_rec;
1612 rc = class_register_type(&mdd_obd_device_ops, NULL, true, NULL,
1613 LUSTRE_MDD_NAME, &mdd_device_type);
1615 lu_kmem_fini(mdd_caches);
1619 static void __exit mdd_exit(void)
1621 class_unregister_type(LUSTRE_MDD_NAME);
1622 lu_kmem_fini(mdd_caches);
1625 MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
1626 MODULE_DESCRIPTION("Lustre Meta-data Device Driver ("LUSTRE_MDD_NAME")");
1627 MODULE_VERSION(LUSTRE_VERSION_STRING);
1628 MODULE_LICENSE("GPL");
1630 module_init(mdd_init);
1631 module_exit(mdd_exit);