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 <obd_class.h>
47 #include <lustre_ioctl.h>
48 #include <lustre_mds.h>
49 #include <obd_support.h>
50 #include <lu_object.h>
51 #include <lustre_param.h>
52 #include <lustre_fid.h>
54 #include "mdd_internal.h"
56 static const struct md_device_operations mdd_ops;
57 static struct lu_device_type mdd_device_type;
59 static const char mdd_root_dir_name[] = "ROOT";
60 static const char mdd_obf_dir_name[] = "fid";
61 static const char mdd_lpf_dir_name[] = "lost+found";
63 /* Slab for MDD object allocation */
64 struct kmem_cache *mdd_object_kmem;
66 static struct lu_kmem_descr mdd_caches[] = {
68 .ckd_cache = &mdd_object_kmem,
69 .ckd_name = "mdd_obj",
70 .ckd_size = sizeof(struct mdd_object)
77 static int mdd_connect_to_next(const struct lu_env *env, struct mdd_device *m,
80 struct obd_connect_data *data = NULL;
81 struct lu_device *lud = mdd2lu_dev(m);
82 struct obd_device *obd;
86 LASSERT(m->mdd_child_exp == NULL);
88 OBD_ALLOC(data, sizeof(*data));
90 GOTO(out, rc = -ENOMEM);
92 obd = class_name2obd(nextdev);
94 CERROR("can't locate next device: %s\n", nextdev);
95 GOTO(out, rc = -ENOTCONN);
98 data->ocd_connect_flags = OBD_CONNECT_VERSION;
99 data->ocd_version = LUSTRE_VERSION_CODE;
101 rc = obd_connect(NULL, &m->mdd_child_exp, obd, &obd->obd_uuid, data, NULL);
103 CERROR("cannot connect to next dev %s (%d)\n", nextdev, rc);
107 lud->ld_site = m->mdd_child_exp->exp_obd->obd_lu_dev->ld_site;
108 LASSERT(lud->ld_site);
109 m->mdd_child = lu2dt_dev(m->mdd_child_exp->exp_obd->obd_lu_dev);
110 m->mdd_bottom = lu2dt_dev(lud->ld_site->ls_bottom_dev);
111 lu_dev_add_linkage(lud->ld_site, lud);
115 OBD_FREE(data, sizeof(*data));
119 static int mdd_init0(const struct lu_env *env, struct mdd_device *mdd,
120 struct lu_device_type *t, struct lustre_cfg *lcfg)
126 dev = lustre_cfg_string(lcfg, 0);
130 mdd->mdd_md_dev.md_lu_dev.ld_obd = class_name2obd(dev);
131 if (mdd->mdd_md_dev.md_lu_dev.ld_obd == NULL)
133 mdd->mdd_md_dev.md_lu_dev.ld_ops = &mdd_lu_ops;
134 mdd->mdd_md_dev.md_ops = &mdd_ops;
136 rc = mdd_connect_to_next(env, mdd, lustre_cfg_string(lcfg, 3));
140 mdd->mdd_atime_diff = MAX_ATIME_DIFF;
141 /* sync permission changes */
142 mdd->mdd_sync_permission = 1;
144 dt_conf_get(env, mdd->mdd_child, &mdd->mdd_dt_conf);
146 /* we are using service name but not mdd obd name
147 * for compatibility reasons.
148 * It is passed from MDT in lustre_cfg[2] buffer */
149 rc = mdd_procfs_init(mdd, lustre_cfg_string(lcfg, 2));
151 obd_disconnect(mdd->mdd_child_exp);
156 static struct lu_device *mdd_device_fini(const struct lu_env *env,
159 struct mdd_device *mdd = lu2mdd_dev(d);
162 lu_dev_del_linkage(d->ld_site, d);
164 mdd_procfs_fini(mdd);
168 static int changelog_init_cb(const struct lu_env *env, struct llog_handle *llh,
169 struct llog_rec_hdr *hdr, void *data)
171 struct mdd_device *mdd = (struct mdd_device *)data;
172 struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
174 LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
175 LASSERT(rec->cr_hdr.lrh_type == CHANGELOG_REC);
178 "seeing record at index %d/%d/"LPU64" t=%x %.*s in log"
179 DOSTID"\n", hdr->lrh_index, rec->cr_hdr.lrh_index,
180 rec->cr.cr_index, rec->cr.cr_type, rec->cr.cr_namelen,
181 changelog_rec_name(&rec->cr), POSTID(&llh->lgh_id.lgl_oi));
183 mdd->mdd_cl.mc_index = rec->cr.cr_index;
184 return LLOG_PROC_BREAK;
187 static int changelog_user_init_cb(const struct lu_env *env,
188 struct llog_handle *llh,
189 struct llog_rec_hdr *hdr, void *data)
191 struct mdd_device *mdd = (struct mdd_device *)data;
192 struct llog_changelog_user_rec *rec =
193 (struct llog_changelog_user_rec *)hdr;
195 LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
196 LASSERT(rec->cur_hdr.lrh_type == CHANGELOG_USER_REC);
198 CDEBUG(D_INFO, "seeing user at index %d/%d id=%d endrec="LPU64
199 " in log "DOSTID"\n", hdr->lrh_index, rec->cur_hdr.lrh_index,
200 rec->cur_id, rec->cur_endrec, POSTID(&llh->lgh_id.lgl_oi));
202 spin_lock(&mdd->mdd_cl.mc_user_lock);
203 mdd->mdd_cl.mc_lastuser = rec->cur_id;
204 if (rec->cur_endrec > mdd->mdd_cl.mc_index)
205 mdd->mdd_cl.mc_index = rec->cur_endrec;
206 spin_unlock(&mdd->mdd_cl.mc_user_lock);
208 return LLOG_PROC_BREAK;
211 static int llog_changelog_cancel_cb(const struct lu_env *env,
212 struct llog_handle *llh,
213 struct llog_rec_hdr *hdr, void *data)
215 struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
216 struct llog_cookie cookie;
217 long long endrec = *(long long *)data;
222 /* This is always a (sub)log, not the catalog */
223 LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
225 if (rec->cr.cr_index > endrec)
226 /* records are in order, so we're done */
227 RETURN(LLOG_PROC_BREAK);
229 cookie.lgc_lgl = llh->lgh_id;
230 cookie.lgc_index = hdr->lrh_index;
232 /* cancel them one at a time. I suppose we could store up the cookies
233 * and cancel them all at once; probably more efficient, but this is
234 * done as a user call, so who cares... */
235 rc = llog_cat_cancel_records(env, llh->u.phd.phd_cat_handle, 1,
237 RETURN(rc < 0 ? rc : 0);
240 static int llog_changelog_cancel(const struct lu_env *env,
241 struct llog_ctxt *ctxt,
242 struct llog_cookie *cookies, int flags)
244 struct llog_handle *cathandle = ctxt->loc_handle;
249 /* This should only be called with the catalog handle */
250 LASSERT(cathandle->lgh_hdr->llh_flags & LLOG_F_IS_CAT);
252 rc = llog_cat_process(env, cathandle, llog_changelog_cancel_cb,
253 (void *)cookies, 0, 0);
255 /* 0 or 1 means we're done */
258 CERROR("%s: cancel idx %u of catalog "DOSTID" rc=%d\n",
259 ctxt->loc_obd->obd_name, cathandle->lgh_last_idx,
260 POSTID(&cathandle->lgh_id.lgl_oi), rc);
265 static struct llog_operations changelog_orig_logops;
268 mdd_changelog_on(const struct lu_env *env, struct mdd_device *mdd, int on);
270 static int mdd_changelog_llog_init(const struct lu_env *env,
271 struct mdd_device *mdd)
273 struct obd_device *obd = mdd2obd_dev(mdd);
274 struct llog_ctxt *ctxt = NULL, *uctxt = NULL;
279 /* LU-2844 mdd setup failure should not cause umount oops */
280 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_CHANGELOG_INIT))
283 OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
284 obd->obd_lvfs_ctxt.dt = mdd->mdd_bottom;
285 rc = llog_setup(env, obd, &obd->obd_olg, LLOG_CHANGELOG_ORIG_CTXT,
286 obd, &changelog_orig_logops);
288 CERROR("%s: changelog llog setup failed: rc = %d\n",
293 ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
296 rc = llog_open_create(env, ctxt, &ctxt->loc_handle, NULL,
299 GOTO(out_cleanup, rc);
301 rc = llog_cat_init_and_process(env, ctxt->loc_handle);
305 rc = llog_cat_reverse_process(env, ctxt->loc_handle,
306 changelog_init_cb, mdd);
309 CERROR("%s: changelog init failed: rc = %d\n", obd->obd_name,
314 CDEBUG(D_IOCTL, "changelog starting index="LPU64"\n",
315 mdd->mdd_cl.mc_index);
317 /* setup user changelog */
318 rc = llog_setup(env, obd, &obd->obd_olg, LLOG_CHANGELOG_USER_ORIG_CTXT,
319 obd, &changelog_orig_logops);
321 CERROR("%s: changelog users llog setup failed: rc = %d\n",
326 uctxt = llog_get_context(obd, LLOG_CHANGELOG_USER_ORIG_CTXT);
329 rc = llog_open_create(env, uctxt, &uctxt->loc_handle, NULL,
332 GOTO(out_ucleanup, rc);
334 uctxt->loc_handle->lgh_logops->lop_add = llog_cat_add_rec;
335 uctxt->loc_handle->lgh_logops->lop_declare_add = llog_cat_declare_add_rec;
337 rc = llog_cat_init_and_process(env, uctxt->loc_handle);
339 GOTO(out_uclose, rc);
341 rc = llog_cat_reverse_process(env, uctxt->loc_handle,
342 changelog_user_init_cb, mdd);
344 CERROR("%s: changelog user init failed: rc = %d\n",
346 GOTO(out_uclose, rc);
349 /* If we have registered users, assume we want changelogs on */
350 if (mdd->mdd_cl.mc_lastuser > 0) {
351 rc = mdd_changelog_on(env, mdd, 1);
353 GOTO(out_uclose, rc);
356 llog_ctxt_put(uctxt);
359 llog_cat_close(env, uctxt->loc_handle);
361 llog_cleanup(env, uctxt);
363 llog_cat_close(env, ctxt->loc_handle);
365 llog_cleanup(env, ctxt);
369 static int mdd_changelog_init(const struct lu_env *env, struct mdd_device *mdd)
371 struct obd_device *obd = mdd2obd_dev(mdd);
374 mdd->mdd_cl.mc_index = 0;
375 spin_lock_init(&mdd->mdd_cl.mc_lock);
376 mdd->mdd_cl.mc_starttime = cfs_time_current_64();
377 mdd->mdd_cl.mc_flags = 0; /* off by default */
378 mdd->mdd_cl.mc_mask = CHANGELOG_DEFMASK;
379 spin_lock_init(&mdd->mdd_cl.mc_user_lock);
380 mdd->mdd_cl.mc_lastuser = 0;
382 rc = mdd_changelog_llog_init(env, mdd);
384 CERROR("%s: changelog setup during init failed: rc = %d\n",
386 mdd->mdd_cl.mc_flags |= CLM_ERR;
392 static void mdd_changelog_fini(const struct lu_env *env,
393 struct mdd_device *mdd)
395 struct obd_device *obd = mdd2obd_dev(mdd);
396 struct llog_ctxt *ctxt;
398 mdd->mdd_cl.mc_flags = 0;
400 ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
402 llog_cat_close(env, ctxt->loc_handle);
403 llog_cleanup(env, ctxt);
405 ctxt = llog_get_context(obd, LLOG_CHANGELOG_USER_ORIG_CTXT);
407 llog_cat_close(env, ctxt->loc_handle);
408 llog_cleanup(env, ctxt);
413 mdd_changelog_write_header(const struct lu_env *env, struct mdd_device *mdd,
416 /* Start / stop recording */
418 mdd_changelog_on(const struct lu_env *env, struct mdd_device *mdd, int on)
422 if ((on == 1) && ((mdd->mdd_cl.mc_flags & CLM_ON) == 0)) {
423 LCONSOLE_INFO("%s: changelog on\n", mdd2obd_dev(mdd)->obd_name);
424 if (mdd->mdd_cl.mc_flags & CLM_ERR) {
425 CERROR("Changelogs cannot be enabled due to error "
426 "condition (see %s log).\n",
427 mdd2obd_dev(mdd)->obd_name);
430 spin_lock(&mdd->mdd_cl.mc_lock);
431 mdd->mdd_cl.mc_flags |= CLM_ON;
432 spin_unlock(&mdd->mdd_cl.mc_lock);
433 rc = mdd_changelog_write_header(env, mdd, CLM_START);
435 } else if ((on == 0) && ((mdd->mdd_cl.mc_flags & CLM_ON) == CLM_ON)) {
436 LCONSOLE_INFO("%s: changelog off\n",mdd2obd_dev(mdd)->obd_name);
437 rc = mdd_changelog_write_header(env, mdd, CLM_FINI);
438 spin_lock(&mdd->mdd_cl.mc_lock);
439 mdd->mdd_cl.mc_flags &= ~CLM_ON;
440 spin_unlock(&mdd->mdd_cl.mc_lock);
445 /** Remove entries with indicies up to and including \a endrec from the
452 mdd_changelog_llog_cancel(const struct lu_env *env, struct mdd_device *mdd,
455 struct obd_device *obd = mdd2obd_dev(mdd);
456 struct llog_ctxt *ctxt;
457 long long unsigned cur;
460 ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
464 spin_lock(&mdd->mdd_cl.mc_lock);
465 cur = (long long)mdd->mdd_cl.mc_index;
466 spin_unlock(&mdd->mdd_cl.mc_lock);
470 /* purge to "0" is shorthand for everything */
474 /* If purging all records, write a header entry so we don't have an
475 empty catalog and we're sure to have a valid starting index next
476 time. In case of crash, we just restart with old log so we're
479 /* XXX: transaction is started by llog itself */
480 rc = mdd_changelog_write_header(env, mdd, CLM_PURGE);
485 /* Some records were purged, so reset repeat-access time (so we
486 record new mtime update records, so users can see a file has been
487 changed since the last purge) */
488 mdd->mdd_cl.mc_starttime = cfs_time_current_64();
490 rc = llog_cancel(env, ctxt, (struct llog_cookie *)&endrec, 0);
496 /** Add a CL_MARK record to the changelog
498 * \param markerflags - CLM_*
501 int mdd_changelog_write_header(const struct lu_env *env,
502 struct mdd_device *mdd, int markerflags)
504 struct obd_device *obd = mdd2obd_dev(mdd);
505 struct llog_changelog_rec *rec;
507 struct llog_ctxt *ctxt;
509 int len = strlen(obd->obd_name);
514 if (mdd->mdd_cl.mc_mask & (1 << CL_MARK)) {
515 mdd->mdd_cl.mc_starttime = cfs_time_current_64();
519 reclen = llog_data_len(sizeof(*rec) + len);
520 buf = lu_buf_check_and_alloc(&mdd_env_info(env)->mti_big_buf, reclen);
521 if (buf->lb_buf == NULL)
525 rec->cr.cr_flags = CLF_VERSION;
526 rec->cr.cr_type = CL_MARK;
527 rec->cr.cr_namelen = len;
528 memcpy(changelog_rec_name(&rec->cr), obd->obd_name, rec->cr.cr_namelen);
529 /* Status and action flags */
530 rec->cr.cr_markerflags = mdd->mdd_cl.mc_flags | markerflags;
531 rec->cr_hdr.lrh_len = llog_data_len(changelog_rec_size(&rec->cr) +
533 rec->cr_hdr.lrh_type = CHANGELOG_REC;
534 rec->cr.cr_time = cl_time();
535 spin_lock(&mdd->mdd_cl.mc_lock);
536 rec->cr.cr_index = ++mdd->mdd_cl.mc_index;
537 spin_unlock(&mdd->mdd_cl.mc_lock);
539 ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
542 rc = llog_cat_add(env, ctxt->loc_handle, &rec->cr_hdr, NULL);
547 /* assume on or off event; reset repeat-access time */
548 mdd->mdd_cl.mc_starttime = cfs_time_current_64();
553 * Lookup method for "fid" object. Only filenames with correct SEQ:OID format
554 * are valid. We also check if object with passed fid exists or not.
556 static int obf_lookup(const struct lu_env *env, struct md_object *p,
557 const struct lu_name *lname, struct lu_fid *f,
558 struct md_op_spec *spec)
560 char *name = (char *)lname->ln_name;
561 struct mdd_device *mdd = mdo2mdd(p);
562 struct mdd_object *child;
568 sscanf(name, SFID, RFID(f));
569 if (!fid_is_sane(f)) {
570 CWARN("%s: Trying to lookup invalid FID [%s] in %s/%s, FID "
571 "format should be "DFID"\n", mdd2obd_dev(mdd)->obd_name,
572 lname->ln_name, dot_lustre_name, mdd_obf_dir_name,
573 (__u64)FID_SEQ_NORMAL, 1, 0);
574 GOTO(out, rc = -EINVAL);
577 if (!fid_is_norm(f) && !fid_is_igif(f) && !fid_is_root(f) &&
578 !fid_seq_is_dot(f->f_seq)) {
579 CWARN("%s: Trying to lookup invalid FID "DFID" in %s/%s, "
580 "sequence should be >= "LPX64" or within ["LPX64","
581 ""LPX64"].\n", mdd2obd_dev(mdd)->obd_name, PFID(f),
582 dot_lustre_name, mdd_obf_dir_name, (__u64)FID_SEQ_NORMAL,
583 (__u64)FID_SEQ_IGIF, (__u64)FID_SEQ_IGIF_MAX);
584 GOTO(out, rc = -EINVAL);
587 /* Check if object with this fid exists */
588 child = mdd_object_find(env, mdd, f);
590 GOTO(out, rc = PTR_ERR(child));
592 if (mdd_object_exists(child) == 0)
595 mdd_object_put(env, child);
601 static int mdd_dummy_create(const struct lu_env *env,
602 struct md_object *pobj,
603 const struct lu_name *lname,
604 struct md_object *child,
605 struct md_op_spec *spec,
611 static int mdd_dummy_rename(const struct lu_env *env,
612 struct md_object *src_pobj,
613 struct md_object *tgt_pobj,
614 const struct lu_fid *lf,
615 const struct lu_name *lsname,
616 struct md_object *tobj,
617 const struct lu_name *ltname,
623 static int mdd_dummy_link(const struct lu_env *env,
624 struct md_object *tgt_obj,
625 struct md_object *src_obj,
626 const struct lu_name *lname,
632 static int mdd_dummy_unlink(const struct lu_env *env,
633 struct md_object *pobj,
634 struct md_object *cobj,
635 const struct lu_name *lname,
642 static struct md_dir_operations mdd_obf_dir_ops = {
643 .mdo_lookup = obf_lookup,
644 .mdo_create = mdd_dummy_create,
645 .mdo_rename = mdd_dummy_rename,
646 .mdo_link = mdd_dummy_link,
647 .mdo_unlink = mdd_dummy_unlink
650 static struct md_dir_operations mdd_lpf_dir_ops = {
651 .mdo_lookup = mdd_lookup,
652 .mdo_create = mdd_dummy_create,
653 .mdo_rename = mdd_dummy_rename,
654 .mdo_link = mdd_dummy_link,
655 .mdo_unlink = mdd_dummy_unlink
658 static struct md_object *mdo_locate(const struct lu_env *env,
659 struct md_device *md,
660 const struct lu_fid *fid)
662 struct lu_object *obj;
663 struct md_object *mdo;
665 obj = lu_object_find(env, &md->md_lu_dev, fid, NULL);
667 obj = lu_object_locate(obj->lo_header, md->md_lu_dev.ld_type);
668 LASSERT(obj != NULL);
671 mdo = ERR_PTR(PTR_ERR(obj));
676 static int mdd_lpf_setup(const struct lu_env *env, struct mdd_device *m)
678 struct md_object *mdo;
679 struct mdd_object *mdd_lpf;
680 struct lu_fid fid = LU_LPF_FID;
684 rc = mdd_local_file_create(env, m, mdd_object_fid(m->mdd_dot_lustre),
685 mdd_lpf_dir_name, S_IFDIR | S_IRUSR | S_IXUSR,
690 mdo = mdo_locate(env, &m->mdd_md_dev, &fid);
692 RETURN(PTR_ERR(mdo));
694 LASSERT(lu_object_exists(&mdo->mo_lu));
696 mdd_lpf = md2mdd_obj(mdo);
697 mdd_lpf->mod_obj.mo_dir_ops = &mdd_lpf_dir_ops;
698 m->mdd_dot_lustre_objs.mdd_lpf = mdd_lpf;
704 * Create special in-memory "fid" object for open-by-fid.
706 static int mdd_obf_setup(const struct lu_env *env, struct mdd_device *m)
708 struct md_object *mdo;
709 struct mdd_object *mdd_obf;
710 struct lu_fid fid = LU_OBF_FID;
713 rc = mdd_local_file_create(env, m, mdd_object_fid(m->mdd_dot_lustre),
714 mdd_obf_dir_name, S_IFDIR | S_IXUSR, &fid);
718 mdo = mdo_locate(env, &m->mdd_md_dev, &fid);
720 RETURN(PTR_ERR(mdo));
722 LASSERT(lu_object_exists(&mdo->mo_lu));
724 mdd_obf = md2mdd_obj(mdo);
725 mdd_obf->mod_obj.mo_dir_ops = &mdd_obf_dir_ops;
726 m->mdd_dot_lustre_objs.mdd_obf = mdd_obf;
731 static void mdd_dot_lustre_cleanup(const struct lu_env *env,
732 struct mdd_device *m)
734 if (m->mdd_dot_lustre_objs.mdd_lpf != NULL) {
735 mdd_object_put(env, m->mdd_dot_lustre_objs.mdd_lpf);
736 m->mdd_dot_lustre_objs.mdd_lpf = NULL;
738 if (m->mdd_dot_lustre_objs.mdd_obf != NULL) {
739 mdd_object_put(env, m->mdd_dot_lustre_objs.mdd_obf);
740 m->mdd_dot_lustre_objs.mdd_obf = NULL;
742 if (m->mdd_dot_lustre != NULL) {
743 mdd_object_put(env, m->mdd_dot_lustre);
744 m->mdd_dot_lustre = NULL;
748 /** Setup ".lustre" directory object */
749 static int mdd_dot_lustre_setup(const struct lu_env *env, struct mdd_device *m)
751 struct md_object *mdo;
756 /* Create ".lustre" directory in ROOT. */
757 fid = LU_DOT_LUSTRE_FID;
758 rc = mdd_local_file_create(env, m, &m->mdd_root_fid,
760 S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO,
764 mdo = mdo_locate(env, &m->mdd_md_dev, &fid);
766 RETURN(PTR_ERR(mdo));
767 LASSERT(lu_object_exists(&mdo->mo_lu));
769 m->mdd_dot_lustre = md2mdd_obj(mdo);
771 rc = mdd_obf_setup(env, m);
773 CERROR("%s: error initializing \"fid\" object: rc = %d.\n",
774 mdd2obd_dev(m)->obd_name, rc);
778 rc = mdd_lpf_setup(env, m);
780 CERROR("%s: error initializing \"lost+found\": rc = %d.\n",
781 mdd2obd_dev(m)->obd_name, rc);
788 mdd_dot_lustre_cleanup(env, m);
794 static struct llog_operations hsm_actions_logops;
797 * set llog methods and create LLOG_AGENT_ORIG_CTXT llog
798 * object in obd_device
800 static int mdd_hsm_actions_llog_init(const struct lu_env *env,
801 struct mdd_device *m)
803 struct obd_device *obd = mdd2obd_dev(m);
804 struct llog_ctxt *ctxt = NULL;
808 OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
809 obd->obd_lvfs_ctxt.dt = m->mdd_bottom;
811 rc = llog_setup(env, obd, &obd->obd_olg, LLOG_AGENT_ORIG_CTXT,
812 obd, &hsm_actions_logops);
814 CERROR("%s: hsm actions llog setup failed: rc = %d\n",
819 ctxt = llog_get_context(obd, LLOG_AGENT_ORIG_CTXT);
822 rc = llog_open_create(env, ctxt, &ctxt->loc_handle, NULL,
825 CERROR("%s: hsm actions llog open_create failed: rc = %d\n",
827 GOTO(out_cleanup, rc);
830 rc = llog_cat_init_and_process(env, ctxt->loc_handle);
838 llog_cat_close(env, ctxt->loc_handle);
839 ctxt->loc_handle = NULL;
841 llog_cleanup(env, ctxt);
847 * cleanup the context created by llog_setup_named()
849 static int mdd_hsm_actions_llog_fini(const struct lu_env *env,
850 struct mdd_device *m)
852 struct obd_device *obd = mdd2obd_dev(m);
853 struct llog_ctxt *lctxt;
856 lctxt = llog_get_context(obd, LLOG_AGENT_ORIG_CTXT);
858 llog_cat_close(env, lctxt->loc_handle);
859 lctxt->loc_handle = NULL;
860 llog_cleanup(env, lctxt);
866 static void mdd_device_shutdown(const struct lu_env *env, struct mdd_device *m,
867 struct lustre_cfg *cfg)
869 mdd_generic_thread_stop(&m->mdd_orph_cleanup_thread);
870 lfsck_degister(env, m->mdd_bottom);
871 mdd_hsm_actions_llog_fini(env, m);
872 mdd_changelog_fini(env, m);
873 orph_index_fini(env, m);
874 mdd_dot_lustre_cleanup(env, m);
875 if (m->mdd_los != NULL) {
876 local_oid_storage_fini(env, m->mdd_los);
879 lu_site_purge(env, mdd2lu_dev(m)->ld_site, ~0);
881 if (m->mdd_child_exp)
882 obd_disconnect(m->mdd_child_exp);
885 static int mdd_process_config(const struct lu_env *env,
886 struct lu_device *d, struct lustre_cfg *cfg)
888 struct mdd_device *m = lu2mdd_dev(d);
889 struct dt_device *dt = m->mdd_child;
890 struct lu_device *next = &dt->dd_lu_dev;
894 switch (cfg->lcfg_command) {
896 struct obd_device *obd = mdd2obd_dev(m);
898 rc = class_process_proc_param(PARAM_MDD, obd->obd_vars, cfg, m);
899 if (rc > 0 || rc == -ENOSYS)
900 /* we don't understand; pass it on */
901 rc = next->ld_ops->ldo_process_config(env, next, cfg);
905 rc = next->ld_ops->ldo_process_config(env, next, cfg);
908 dt_conf_get(env, dt, &m->mdd_dt_conf);
911 rc = next->ld_ops->ldo_process_config(env, next, cfg);
912 lu_dev_del_linkage(d->ld_site, d);
913 mdd_device_shutdown(env, m, cfg);
916 rc = next->ld_ops->ldo_process_config(env, next, cfg);
923 static int mdd_recovery_complete(const struct lu_env *env,
926 struct mdd_device *mdd = lu2mdd_dev(d);
927 struct lu_device *next;
931 LASSERT(mdd != NULL);
932 next = &mdd->mdd_child->dd_lu_dev;
934 /* XXX: orphans handling. */
935 mdd_orphan_cleanup(env, mdd);
936 rc = next->ld_ops->ldo_recovery_complete(env, next);
941 int mdd_local_file_create(const struct lu_env *env, struct mdd_device *mdd,
942 const struct lu_fid *pfid, const char *name, __u32 mode,
945 struct dt_object *parent, *dto;
950 LASSERT(!fid_is_zero(pfid));
951 parent = dt_locate(env, mdd->mdd_bottom, pfid);
952 if (unlikely(IS_ERR(parent)))
953 RETURN(PTR_ERR(parent));
955 /* create local file/dir, if @fid is passed then try to use it */
956 if (fid_is_zero(fid))
957 dto = local_file_find_or_create(env, mdd->mdd_los, parent,
960 dto = local_file_find_or_create_with_fid(env, mdd->mdd_bottom,
964 GOTO(out_put, rc = PTR_ERR(dto));
965 *fid = *lu_object_fid(&dto->do_lu);
966 /* since stack is not fully set up the local_storage uses own stack
967 * and we should drop its object from cache */
968 lu_object_put_nocache(env, &dto->do_lu);
971 lu_object_put(env, &parent->do_lu);
975 static int mdd_lfsck_out_notify(const struct lu_env *env, void *data,
976 enum lfsck_events event)
981 static int mdd_prepare(const struct lu_env *env,
982 struct lu_device *pdev,
983 struct lu_device *cdev)
985 struct mdd_device *mdd = lu2mdd_dev(cdev);
986 struct lu_device *next = &mdd->mdd_child->dd_lu_dev;
992 rc = next->ld_ops->ldo_prepare(env, cdev, next);
996 /* Setup local dirs */
997 fid.f_seq = FID_SEQ_LOCAL_NAME;
1000 rc = local_oid_storage_init(env, mdd->mdd_bottom, &fid,
1005 rc = dt_root_get(env, mdd->mdd_child, &mdd->mdd_local_root_fid);
1010 if (mdd_seq_site(mdd)->ss_node_id == 0) {
1011 rc = mdd_local_file_create(env, mdd, &mdd->mdd_local_root_fid,
1012 mdd_root_dir_name, S_IFDIR |
1013 S_IRUGO | S_IWUSR | S_IXUGO, &fid);
1015 CERROR("%s: create root fid failed: rc = %d\n",
1016 mdd2obd_dev(mdd)->obd_name, rc);
1020 mdd->mdd_root_fid = fid;
1021 rc = mdd_dot_lustre_setup(env, mdd);
1023 CERROR("%s: initializing .lustre failed: rc = %d\n",
1024 mdd2obd_dev(mdd)->obd_name, rc);
1028 rc = mdd_compat_fixes(env, mdd);
1032 /* Normal client usually send root access to MDT0 directly,
1033 * the root FID on non-MDT0 will only be used by echo client. */
1034 mdd->mdd_root_fid = fid;
1037 rc = orph_index_init(env, mdd);
1041 rc = mdd_changelog_init(env, mdd);
1043 CERROR("%s: failed to initialize changelog: rc = %d\n",
1044 mdd2obd_dev(mdd)->obd_name, rc);
1048 rc = mdd_hsm_actions_llog_init(env, mdd);
1050 GOTO(out_changelog, rc);
1052 rc = lfsck_register(env, mdd->mdd_bottom, mdd->mdd_child,
1053 mdd2obd_dev(mdd), mdd_lfsck_out_notify,
1056 CERROR("%s: failed to initialize lfsck: rc = %d\n",
1057 mdd2obd_dev(mdd)->obd_name, rc);
1062 mdd_hsm_actions_llog_fini(env, mdd);
1064 mdd_changelog_fini(env, mdd);
1066 orph_index_fini(env, mdd);
1068 if (mdd_seq_site(mdd)->ss_node_id == 0)
1069 mdd_dot_lustre_cleanup(env, mdd);
1071 local_oid_storage_fini(env, mdd->mdd_los);
1072 mdd->mdd_los = NULL;
1077 const struct lu_device_operations mdd_lu_ops = {
1078 .ldo_object_alloc = mdd_object_alloc,
1079 .ldo_process_config = mdd_process_config,
1080 .ldo_recovery_complete = mdd_recovery_complete,
1081 .ldo_prepare = mdd_prepare,
1084 static int mdd_root_get(const struct lu_env *env,
1085 struct md_device *m, struct lu_fid *f)
1087 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
1090 *f = mdd->mdd_root_fid;
1095 * No permission check is needed.
1097 static int mdd_statfs(const struct lu_env *env, struct md_device *m,
1098 struct obd_statfs *sfs)
1100 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
1105 rc = mdd_child_ops(mdd)->dt_statfs(env, mdd->mdd_child, sfs);
1107 sfs->os_namelen = min_t(__u32, sfs->os_namelen, NAME_MAX);
1113 * No permission check is needed.
1115 static int mdd_init_capa_ctxt(const struct lu_env *env, struct md_device *m,
1116 int mode, unsigned long timeout, __u32 alg,
1117 struct lustre_capa_key *keys)
1119 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
1123 /* need barrier for mds_capa_keys access. */
1125 rc = mdd_child_ops(mdd)->dt_init_capa_ctxt(env, mdd->mdd_child, mode,
1126 timeout, alg, keys);
1130 static int mdd_maxeasize_get(const struct lu_env *env, struct md_device *m,
1133 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
1136 *easize = mdd->mdd_dt_conf.ddp_max_ea_size;
1141 static int mdd_update_capa_key(const struct lu_env *env,
1142 struct md_device *m,
1143 struct lustre_capa_key *key)
1145 /* we do not support capabilities ... */
1149 static int mdd_llog_ctxt_get(const struct lu_env *env, struct md_device *m,
1152 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
1154 *h = llog_group_get_ctxt(&mdd2obd_dev(mdd)->obd_olg, idx);
1155 return (*h == NULL ? -ENOENT : 0);
1158 static struct lu_device *mdd_device_free(const struct lu_env *env,
1159 struct lu_device *lu)
1161 struct mdd_device *m = lu2mdd_dev(lu);
1164 LASSERT(atomic_read(&lu->ld_ref) == 0);
1165 md_device_fini(&m->mdd_md_dev);
1170 static struct lu_device *mdd_device_alloc(const struct lu_env *env,
1171 struct lu_device_type *t,
1172 struct lustre_cfg *lcfg)
1174 struct lu_device *l;
1175 struct mdd_device *m;
1179 l = ERR_PTR(-ENOMEM);
1184 md_device_init(&m->mdd_md_dev, t);
1185 rc = mdd_init0(env, m, t, lcfg);
1187 mdd_device_free(env, l);
1196 * we use exports to track all mdd users
1198 static int mdd_obd_connect(const struct lu_env *env, struct obd_export **exp,
1199 struct obd_device *obd, struct obd_uuid *cluuid,
1200 struct obd_connect_data *data, void *localdata)
1202 struct mdd_device *mdd = lu2mdd_dev(obd->obd_lu_dev);
1203 struct lustre_handle conn;
1207 CDEBUG(D_CONFIG, "connect #%d\n", mdd->mdd_connects);
1209 rc = class_connect(&conn, obd, cluuid);
1213 *exp = class_conn2export(&conn);
1215 /* Why should there ever be more than 1 connect? */
1216 LASSERT(mdd->mdd_connects == 0);
1217 mdd->mdd_connects++;
1223 * once last export (we don't count self-export) disappeared
1224 * mdd can be released
1226 static int mdd_obd_disconnect(struct obd_export *exp)
1228 struct obd_device *obd = exp->exp_obd;
1229 struct mdd_device *mdd = lu2mdd_dev(obd->obd_lu_dev);
1230 int rc, release = 0;
1233 mdd->mdd_connects--;
1234 if (mdd->mdd_connects == 0)
1237 rc = class_disconnect(exp);
1239 if (rc == 0 && release)
1240 class_manual_cleanup(obd);
1244 static int mdd_obd_get_info(const struct lu_env *env, struct obd_export *exp,
1245 __u32 keylen, void *key, __u32 *vallen, void *val,
1246 struct lov_stripe_md *lsm)
1250 if (KEY_IS(KEY_OSP_CONNECTED)) {
1251 struct obd_device *obd = exp->exp_obd;
1252 struct mdd_device *mdd;
1254 if (!obd->obd_set_up || obd->obd_stopping)
1257 mdd = lu2mdd_dev(obd->obd_lu_dev);
1259 rc = obd_get_info(env, mdd->mdd_child_exp, keylen, key, vallen,
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,
1274 static int mdd_changelog_user_register(const struct lu_env *env,
1275 struct mdd_device *mdd, int *id)
1277 struct llog_ctxt *ctxt;
1278 struct llog_changelog_user_rec *rec;
1282 ctxt = llog_get_context(mdd2obd_dev(mdd),
1283 LLOG_CHANGELOG_USER_ORIG_CTXT);
1289 llog_ctxt_put(ctxt);
1293 /* Assume we want it on since somebody registered */
1294 rc = mdd_changelog_on(env, mdd, 1);
1298 rec->cur_hdr.lrh_len = sizeof(*rec);
1299 rec->cur_hdr.lrh_type = CHANGELOG_USER_REC;
1300 spin_lock(&mdd->mdd_cl.mc_user_lock);
1301 if (mdd->mdd_cl.mc_lastuser == (unsigned int)(-1)) {
1302 spin_unlock(&mdd->mdd_cl.mc_user_lock);
1303 CERROR("Maximum number of changelog users exceeded!\n");
1304 GOTO(out, rc = -EOVERFLOW);
1306 *id = rec->cur_id = ++mdd->mdd_cl.mc_lastuser;
1307 rec->cur_endrec = mdd->mdd_cl.mc_index;
1308 spin_unlock(&mdd->mdd_cl.mc_user_lock);
1310 rc = llog_cat_add(env, ctxt->loc_handle, &rec->cur_hdr, NULL);
1312 CDEBUG(D_IOCTL, "Registered changelog user %d\n", *id);
1315 llog_ctxt_put(ctxt);
1319 struct mdd_changelog_user_data {
1320 __u64 mcud_endrec; /**< purge record for this user */
1321 __u64 mcud_minrec; /**< lowest changelog recno still referenced */
1323 __u32 mcud_minid; /**< user id with lowest rec reference */
1324 __u32 mcud_usercount;
1325 unsigned int mcud_found:1;
1327 #define MCUD_UNREGISTER -1LL
1330 * 1. Find the smallest record everyone is willing to purge
1331 * 2. Update the last purgeable record for this user
1333 static int mdd_changelog_user_purge_cb(const struct lu_env *env,
1334 struct llog_handle *llh,
1335 struct llog_rec_hdr *hdr, void *data)
1337 struct llog_changelog_user_rec *rec;
1338 struct mdd_changelog_user_data *mcud = data;
1343 LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
1345 rec = (struct llog_changelog_user_rec *)hdr;
1347 mcud->mcud_usercount++;
1349 /* If we have a new endrec for this id, use it for the following
1350 min check instead of its old value */
1351 if (rec->cur_id == mcud->mcud_id)
1352 rec->cur_endrec = max(rec->cur_endrec, mcud->mcud_endrec);
1354 /* Track the minimum referenced record */
1355 if (mcud->mcud_minid == 0 || mcud->mcud_minrec > rec->cur_endrec) {
1356 mcud->mcud_minid = rec->cur_id;
1357 mcud->mcud_minrec = rec->cur_endrec;
1360 if (rec->cur_id != mcud->mcud_id)
1363 /* Update this user's record */
1364 mcud->mcud_found = 1;
1366 /* Special case: unregister this user */
1367 if (mcud->mcud_endrec == MCUD_UNREGISTER) {
1368 struct llog_cookie cookie;
1370 cookie.lgc_lgl = llh->lgh_id;
1371 cookie.lgc_index = hdr->lrh_index;
1373 rc = llog_cat_cancel_records(env, llh->u.phd.phd_cat_handle,
1376 mcud->mcud_usercount--;
1381 /* Update the endrec */
1382 CDEBUG(D_IOCTL, "Rewriting changelog user %d endrec to "LPU64"\n",
1383 mcud->mcud_id, rec->cur_endrec);
1385 rc = llog_write(env, llh, hdr, hdr->lrh_index);
1390 static int mdd_changelog_user_purge(const struct lu_env *env,
1391 struct mdd_device *mdd, int id,
1394 struct mdd_changelog_user_data data;
1395 struct llog_ctxt *ctxt;
1399 CDEBUG(D_IOCTL, "Purge request: id=%d, endrec=%lld\n", id, endrec);
1402 data.mcud_minid = 0;
1403 data.mcud_minrec = 0;
1404 data.mcud_usercount = 0;
1405 data.mcud_endrec = endrec;
1406 spin_lock(&mdd->mdd_cl.mc_lock);
1407 endrec = mdd->mdd_cl.mc_index;
1408 spin_unlock(&mdd->mdd_cl.mc_lock);
1409 if ((data.mcud_endrec == 0) ||
1410 ((data.mcud_endrec > endrec) &&
1411 (data.mcud_endrec != MCUD_UNREGISTER)))
1412 data.mcud_endrec = endrec;
1414 ctxt = llog_get_context(mdd2obd_dev(mdd),
1415 LLOG_CHANGELOG_USER_ORIG_CTXT);
1419 LASSERT(ctxt->loc_handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT);
1421 rc = llog_cat_process(env, ctxt->loc_handle,
1422 mdd_changelog_user_purge_cb, (void *)&data,
1424 if ((rc >= 0) && (data.mcud_minrec > 0)) {
1425 CDEBUG(D_IOCTL, "Purging changelog entries up to "LPD64
1426 ", referenced by "CHANGELOG_USER_PREFIX"%d\n",
1427 data.mcud_minrec, data.mcud_minid);
1428 rc = mdd_changelog_llog_cancel(env, mdd, data.mcud_minrec);
1430 CWARN("Could not determine changelog records to purge; rc=%d\n",
1434 llog_ctxt_put(ctxt);
1436 if (!data.mcud_found) {
1437 CWARN("No entry for user %d. Last changelog reference is "
1438 LPD64" by changelog user %d\n", data.mcud_id,
1439 data.mcud_minrec, data.mcud_minid);
1443 if (!rc && data.mcud_usercount == 0)
1444 /* No more users; turn changelogs off */
1445 rc = mdd_changelog_on(env, mdd, 0);
1451 * May be called remotely from mdt_iocontrol_handle or locally from
1452 * mdt_iocontrol. Data may be freeform - remote handling doesn't enforce
1453 * an obd_ioctl_data format (but local ioctl handler does).
1455 * \param len - data len
1456 * \param karg - ioctl data, in kernel space
1458 static int mdd_iocontrol(const struct lu_env *env, struct md_device *m,
1459 unsigned int cmd, int len, void *karg)
1461 struct mdd_device *mdd;
1462 struct obd_ioctl_data *data = karg;
1466 mdd = lu2mdd_dev(&m->md_lu_dev);
1468 /* Doesn't use obd_ioctl_data */
1470 case OBD_IOC_CHANGELOG_CLEAR: {
1471 struct changelog_setinfo *cs = karg;
1472 rc = mdd_changelog_user_purge(env, mdd, cs->cs_id,
1476 case OBD_IOC_GET_MNTOPT: {
1477 mntopt_t *mntopts = (mntopt_t *)karg;
1478 *mntopts = mdd->mdd_dt_conf.ddp_mntopts;
1481 case OBD_IOC_START_LFSCK: {
1482 rc = lfsck_start(env, mdd->mdd_bottom,
1483 (struct lfsck_start_param *)karg);
1486 case OBD_IOC_STOP_LFSCK: {
1487 rc = lfsck_stop(env, mdd->mdd_bottom,
1488 (struct lfsck_stop *)karg);
1493 /* Below ioctls use obd_ioctl_data */
1494 if (len != sizeof(*data)) {
1495 CERROR("Bad ioctl size %d\n", len);
1498 if (data->ioc_version != OBD_IOCTL_VERSION) {
1499 CERROR("Bad magic %x != %x\n", data->ioc_version,
1505 case OBD_IOC_CHANGELOG_REG:
1506 rc = mdd_changelog_user_register(env, mdd, &data->ioc_u32_1);
1508 case OBD_IOC_CHANGELOG_DEREG:
1509 rc = mdd_changelog_user_purge(env, mdd, data->ioc_u32_1,
1519 /* type constructor/destructor: mdd_type_init, mdd_type_fini */
1520 LU_TYPE_INIT_FINI(mdd, &mdd_thread_key);
1522 static const struct md_device_operations mdd_ops = {
1523 .mdo_statfs = mdd_statfs,
1524 .mdo_root_get = mdd_root_get,
1525 .mdo_init_capa_ctxt = mdd_init_capa_ctxt,
1526 .mdo_update_capa_key= mdd_update_capa_key,
1527 .mdo_llog_ctxt_get = mdd_llog_ctxt_get,
1528 .mdo_iocontrol = mdd_iocontrol,
1529 .mdo_maxeasize_get = mdd_maxeasize_get,
1532 static struct lu_device_type_operations mdd_device_type_ops = {
1533 .ldto_init = mdd_type_init,
1534 .ldto_fini = mdd_type_fini,
1536 .ldto_start = mdd_type_start,
1537 .ldto_stop = mdd_type_stop,
1539 .ldto_device_alloc = mdd_device_alloc,
1540 .ldto_device_free = mdd_device_free,
1542 .ldto_device_fini = mdd_device_fini
1545 static struct lu_device_type mdd_device_type = {
1546 .ldt_tags = LU_DEVICE_MD,
1547 .ldt_name = LUSTRE_MDD_NAME,
1548 .ldt_ops = &mdd_device_type_ops,
1549 .ldt_ctx_tags = LCT_MD_THREAD
1552 /* context key constructor: mdd_key_init */
1553 LU_KEY_INIT(mdd, struct mdd_thread_info);
1555 static void mdd_key_fini(const struct lu_context *ctx,
1556 struct lu_context_key *key, void *data)
1558 struct mdd_thread_info *info = data;
1560 lu_buf_free(&info->mti_big_buf);
1561 lu_buf_free(&info->mti_link_buf);
1566 /* context key: mdd_thread_key */
1567 LU_CONTEXT_KEY_DEFINE(mdd, LCT_MD_THREAD);
1569 int mdd_generic_thread_start(struct mdd_generic_thread *thread,
1570 int (*func)(void *), void *data, char *name)
1572 struct task_struct *task;
1574 LASSERT(thread->mgt_init == false);
1575 init_completion(&thread->mgt_started);
1576 init_completion(&thread->mgt_finished);
1577 thread->mgt_data = data;
1578 thread->mgt_abort = false;
1579 thread->mgt_init = true;
1581 task = kthread_run(func, thread, name);
1583 complete(&thread->mgt_finished);
1584 return PTR_ERR(task);
1586 wait_for_completion(&thread->mgt_started);
1590 void mdd_generic_thread_stop(struct mdd_generic_thread *thread)
1592 if (thread->mgt_init == true) {
1593 thread->mgt_abort = true;
1594 wait_for_completion(&thread->mgt_finished);
1598 static int __init mdd_mod_init(void)
1602 rc = lu_kmem_init(mdd_caches);
1606 changelog_orig_logops = llog_osd_ops;
1607 changelog_orig_logops.lop_cancel = llog_changelog_cancel;
1608 changelog_orig_logops.lop_add = llog_cat_add_rec;
1609 changelog_orig_logops.lop_declare_add = llog_cat_declare_add_rec;
1611 hsm_actions_logops = llog_osd_ops;
1612 hsm_actions_logops.lop_add = llog_cat_add_rec;
1613 hsm_actions_logops.lop_declare_add = llog_cat_declare_add_rec;
1615 rc = class_register_type(&mdd_obd_device_ops, NULL, true, NULL,
1616 LUSTRE_MDD_NAME, &mdd_device_type);
1618 lu_kmem_fini(mdd_caches);
1622 static void __exit mdd_mod_exit(void)
1624 class_unregister_type(LUSTRE_MDD_NAME);
1625 lu_kmem_fini(mdd_caches);
1628 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
1629 MODULE_DESCRIPTION("Lustre Meta-data Device Prototype ("LUSTRE_MDD_NAME")");
1630 MODULE_LICENSE("GPL");
1632 cfs_module(mdd, "0.1.0", mdd_mod_init, mdd_mod_exit);