RETURN (rc);
}
-int cmm_notify(const struct lu_context *ctxt, struct md_device *md,
- struct obd_device *watched,
- enum obd_notify_event ev, void *data)
-{
- struct cmm_device *cmm_dev = md2cmm_dev(md);
- int rc;
-
- rc = cmm_child_ops(cmm_dev)->mdo_notify(ctxt, cmm_dev->cmm_child,
- watched, ev, data);
-
- return rc;
-}
-
static struct md_device_operations cmm_md_ops = {
.mdo_root_get = cmm_root_get,
.mdo_statfs = cmm_statfs,
- .mdo_notify = cmm_notify
};
extern struct lu_device_type mdc_device_type;
#define IOC_REQUEST_MAX_NR 35
#define MDS_LOV_MD_NAME "lov"
+#define MDD_OBD_NAME "mdd_obd"
+#define MDD_OBD_UUID "mdd_obd_uuid"
+#define MDD_OBD_TYPE "mds"
+#define MDD_OBD_PROFILE "lustre-MDT0000"
+
#endif
struct md_device *m, struct lu_fid *f);
int (*mdo_statfs)(const struct lu_context *ctx,
struct md_device *m, struct kstatfs *sfs);
- /*
- * notify function for metadata stack
- */
- int (*mdo_notify)(const struct lu_context *ctx,
- struct md_device *m, struct obd_device *watched,
- enum obd_notify_event ev, void *data);
-
};
struct md_device {
const void *ctxt);
int (*ml_write_objids)(struct obd_device *obd, struct md_lov_info *mli,
const void *ctxt);
+ int (*ml_read_catlist)(struct obd_device *obd, void *idarray, int size,
+ const void *ctxt);
+ int (*ml_write_catlist)(struct obd_device *obd, void *idarray, int size,
+ const void *ctxt);
+
};
struct md_lov_info {
struct obd_device *md_lov_obd; /* XXX lov_obd */
MODULES := mdd
-mdd-objs := mdd_handler.o mdd_lov.o mdd_obd.o
+mdd-objs := mdd_handler.o mdd_lov.o
@INCLUDE_RULES@
rc = mdd_mount(ctxt, m);
if (rc)
GOTO(out, rc);
- rc = mdd_lov_init(ctxt, m, cfg);
+ rc = mdd_init_obd(ctxt, m);
if (rc) {
CERROR("lov init error %d \n", rc);
GOTO(out, rc);
.loo_object_exists = mdd_object_exists,
};
-
static void mdd_lock(const struct lu_context *ctxt,
struct mdd_object *obj, enum dt_lock_mode mode)
{
struct md_device_operations mdd_ops = {
.mdo_root_get = mdd_root_get,
.mdo_statfs = mdd_statfs,
- .mdo_notify = mdd_notify
};
static struct md_dir_operations mdd_dir_ops = {
#include <asm/semaphore.h>
#include <md_object.h>
-#define MDD_OBD_NAME "mdd_obd"
-#define MDD_OBD_UUID "mdd_obd_uuid"
-#define MDD_OBD_TYPE "mds"
-#define MDD_OBD_PROFILE "lustre-client"
struct dt_device;
struct mdd_device {
struct lov_mds_md mti_lmm;
};
-int mdd_lov_init(const struct lu_context *ctxt, struct mdd_device *mdd,
- struct lustre_cfg *cfg);
-int mdd_lov_fini(const struct lu_context *ctxt, struct mdd_device *mdd);
-int mdd_notify(const struct lu_context *ctxt, struct md_device *md,
- struct obd_device *watched, enum obd_notify_event ev,
- void *data);
-
+int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd);
int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj,
const void *buf, int buf_len, const char *name);
int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj,
const void *ctxt)
{
struct dt_object *obj_ids = mli->md_lov_objid_obj;
- struct lu_attr *lu_attr = &mdd_ctx_info(ctxt)->mti_attr;
+ struct lu_attr *lu_attr = NULL;
obd_id *ids;
int i, rc;
ENTRY;
has fewer targets. Old targets not in the lov descriptor
during mds setup may still have valid objids. */
+ OBD_ALLOC_PTR(lu_attr);
+ if (!lu_attr)
+ GOTO(out, rc = -ENOMEM);
rc = obj_ids->do_ops->do_attr_get(ctxt, obj_ids, lu_attr);
if (rc)
GOTO(out, rc);
mli->md_lov_objids[i], i);
}
out:
+ if (lu_attr)
+ OBD_FREE_PTR(lu_attr);
RETURN(0);
}
#endif
RETURN(rc);
}
+static int mdd_lov_write_catlist(struct obd_device *obd, void *idarray, int size,
+ const void *ctxt)
+{
+ int rc = 0;
+ RETURN(rc);
+}
+
+static int mdd_lov_read_catlist(struct obd_device *obd, void *idarray, int size,
+ const void *ctxt)
+{
+ int rc = 0;
+ RETURN(rc);
+}
struct md_lov_ops mdd_lov_ops = {
.ml_read_objids = mdd_lov_read_objids,
.ml_write_objids = mdd_lov_write_objids,
+ .ml_read_catlist = mdd_lov_read_catlist,
+ .ml_write_catlist = mdd_lov_write_catlist
};
-int mdd_lov_fini(const struct lu_context *ctxt, struct mdd_device *mdd)
+/*The obd is created for handling data stack for mdd*/
+int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd)
{
- struct md_lov_info *mli = &mdd->mdd_lov_info;
-
- obd_register_observer(mli->md_lov_obd, NULL);
-
- if (mli->md_lov_exp) {
- obd_disconnect(mli->md_lov_exp);
- mli->md_lov_exp = NULL;
- }
-
- dt_object_fini(mli->md_lov_objid_obj);
- return 0;
-}
-
-int mdd_lov_init(const struct lu_context *ctxt, struct mdd_device *mdd,
- struct lustre_cfg *cfg)
-{
- struct md_lov_info *lov_info = &mdd->mdd_lov_info;
+ struct lustre_cfg_bufs bufs;
+ struct lustre_cfg *lcfg;
+ struct obd_device *obd;
struct dt_object *obj_id;
- struct obd_device *obd = NULL;
- char *lov_name = NULL, *srv = NULL;
- int rc = 0;
+ struct md_lov_info *mli;
+ int rc;
ENTRY;
-
- if (IS_ERR(lov_info->md_lov_obd))
- RETURN(PTR_ERR(lov_info->md_lov_obd));
-
- lov_name = lustre_cfg_string(cfg, 3);
- LASSERTF(lov_name != NULL, "MDD need lov \n");
-
+
+ lustre_cfg_bufs_reset(&bufs, MDD_OBD_NAME);
+ lustre_cfg_bufs_set_string(&bufs, 1, MDD_OBD_TYPE);
+ lustre_cfg_bufs_set_string(&bufs, 2, MDD_OBD_UUID);
+ lustre_cfg_bufs_set_string(&bufs, 3, MDD_OBD_PROFILE);
+
+ lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs);
+ if (!lcfg)
+ RETURN(-ENOMEM);
+
+ rc = class_attach(lcfg);
+ if (rc)
+ GOTO(lcfg_cleanup, rc);
+
+ obd = class_name2obd(MDD_OBD_NAME);
+ if (!obd) {
+ CERROR("can not find obd %s \n", MDD_OBD_NAME);
+ LBUG();
+ }
+
+ /*init mli, which will be used in following mds setup*/
+ mli = &obd->u.mds.mds_lov_info;
+ mli->md_lov_ops = &mdd_lov_ops;
+
obj_id = dt_store_open(ctxt, mdd->mdd_child, mdd_lov_objid_name,
- &lov_info->md_lov_objid_fid);
+ &mli->md_lov_objid_fid);
if (IS_ERR(obj_id)){
rc = PTR_ERR(obj_id);
RETURN(rc);
}
+ mli->md_lov_objid_obj = obj_id;
- LASSERT(obj_id != NULL);
- lov_info->md_lov_objid_obj = obj_id;
-
- srv = lustre_cfg_string(cfg, 0);
- obd = class_name2obd(srv);
- if (obd == NULL) {
- CERROR("No such OBD %s\n", srv);
- LBUG();
- }
- CDEBUG(D_INFO, "srv name %s, obd %p \n", obd->obd_name, obd);
- rc = md_lov_connect(obd, lov_info, lov_name,
- &obd->obd_uuid, &mdd_lov_ops, ctxt);
- if (rc)
- GOTO(out, rc);
-out:
+ rc = class_setup(obd, lcfg);
if (rc)
- mdd_lov_fini(ctxt, mdd);
+ GOTO(class_detach, rc);
+ mdd->mdd_md_dev.md_lu_dev.ld_obd = obd;
+class_detach:
+ if (rc)
+ class_detach(obd, lcfg);
+lcfg_cleanup:
+ lustre_cfg_free(lcfg);
RETURN(rc);
}
-int mdd_notify(const struct lu_context *ctxt, struct md_device *md,
- struct obd_device *watched,
- enum obd_notify_event ev, void *data)
+int mdd_cleanup_obd(struct mdd_device *mdd)
{
- struct mdd_device *mdd = lu2mdd_dev(&md->md_lu_dev);
- struct obd_device *obd = md2lu_dev(md)->ld_site->ls_top_dev->ld_obd;
- int rc = 0;
+ struct lustre_cfg_bufs bufs;
+ struct md_lov_info *mli;
+ struct lustre_cfg *lcfg;
+ struct obd_device *obd;
+ int rc;
ENTRY;
+
+ obd = mdd->mdd_md_dev.md_lu_dev.ld_obd;
+ LASSERT(obd);
+
+ mli = &obd->u.mds.mds_lov_info;
+ dt_object_fini(mli->md_lov_objid_obj);
+
+ lustre_cfg_bufs_reset(&bufs, MDD_OBD_NAME);
+ lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs);
+ if (!lcfg)
+ RETURN(-ENOMEM);
- rc = md_lov_notity_pre(obd, &mdd->mdd_lov_info, watched, ev, data);
- if (rc) {
- if (rc == -ENOENT || rc == -EBUSY)
- rc = 0;
- RETURN(rc);
- }
-
- rc = md_lov_start_synchronize(obd, &mdd->mdd_lov_info, watched, data,
- !(ev == OBD_NOTIFY_SYNC), ctxt);
-
+ rc = class_cleanup(obd, lcfg);
+ if (rc)
+ GOTO(lcfg_cleanup, rc);
+
+ rc = class_detach(obd, lcfg);
+ if (rc)
+ GOTO(lcfg_cleanup, rc);
+ mdd->mdd_md_dev.md_lu_dev.ld_obd = NULL;
+lcfg_cleanup:
+ lustre_cfg_free(lcfg);
RETURN(rc);
}
struct mdd_object *child, struct lov_mds_md **lmm,
int *lmm_size)
{
- struct md_lov_info *mli = &mdd->mdd_lov_info;
+ struct obd_device *obd = mdd->mdd_md_dev.md_lu_dev.ld_obd;
+ struct obd_export *lov_exp = obd->u.mds.mds_osc_exp;
struct obdo *oa;
struct lov_stripe_md *lsm = NULL;
int rc = 0;
OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID;
oa->o_size = 0;
- rc = obd_create(mli->md_lov_exp, oa, &lsm, NULL);
+ rc = obd_create(lov_exp, oa, &lsm, NULL);
if (rc)
GOTO(out_oa, rc);
- rc = obd_packmd(mli->md_lov_exp, lmm, lsm);
+ rc = obd_packmd(lov_exp, lmm, lsm);
if (rc < 0) {
CERROR("cannot pack lsm, err = %d\n", rc);
GOTO(out_oa, rc);
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * linux/mds/mds_lov.c
- * Lustre Metadata Server (mdd) OBD
- *
- * Copyright (C) 2006 Cluster File Systems, Inc.
- * Author: wangdi <wangdi@clusterfs.com>
- *
- * This file is part of the Lustre file system, http://www.lustre.org
- * Lustre is a trademark of Cluster File Systems, Inc.
- *
- * You may have signed or agreed to another license before downloading
- * this software. If so, you are bound by the terms and conditions
- * of that agreement, and the following does not apply to you. See the
- * LICENSE file included with this distribution for more information.
- *
- * If you did not agree to a different license, then this copy of Lustre
- * is open source software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * In either case, Lustre is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * license text for more details.
- */
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
-#define DEBUG_SUBSYSTEM S_MDS
-
-#include <linux/module.h>
-
-#include <obd.h>
-#include <obd_class.h>
-#include <lustre_ver.h>
-#include <obd_support.h>
-#include <obd_lov.h>
-#include <lprocfs_status.h>
-
-#include <lu_object.h>
-#include <md_object.h>
-#include <dt_object.h>
-#include <lustre_mds.h>
-#include <lustre/lustre_idl.h>
-
-#include "mdd_internal.h"
-
-/*The obd is created for using llog in mdd layer*/
-int mdd_new_obd(struct mdd_device *mdd)
-{
- struct lustre_cfg_bufs bufs;
- struct lustre_cfg *lcfg;
- struct obd_device *obd;
- int rc;
- ENTRY;
-
- lustre_cfg_bufs_reset(&bufs, MDD_OBD_NAME);
- lustre_cfg_bufs_set_string(&bufs, 1, MDD_OBD_TYPE);
- lustre_cfg_bufs_set_string(&bufs, 2, MDD_OBD_UUID);
- lustre_cfg_bufs_set_string(&bufs, 3, MDD_OBD_UUID);
-
- lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs);
- if (!lcfg)
- RETURN(-ENOMEM);
-
- rc = class_attach(lcfg);
- if (rc)
- GOTO(lcfg_cleanup, rc);
-
- obd = class_name2obd(MDD_OBD_NAME);
- if (!obd) {
- CERROR("can not find obd %s \n", MDD_OBD_NAME);
- LBUG();
- }
-
- rc = class_setup(obd, lcfg);
- if (rc)
- GOTO(class_detach, rc);
-
- mdd->mdd_md_dev.md_lu_dev.ld_obd = obd;
-class_detach:
- if (rc)
- class_detach(obd, lcfg);
-lcfg_cleanup:
- lustre_cfg_free(lcfg);
- RETURN(rc);
-}
-
-int mdd_cleanup_obd(struct mdd_device *mdd)
-{
- struct lustre_cfg_bufs bufs;
- struct lustre_cfg *lcfg;
- struct obd_device *obd;
- int rc;
- ENTRY;
-
- obd = mdd->mdd_md_dev.md_lu_dev.ld_obd;
- LASSERT(obd);
- lustre_cfg_bufs_reset(&bufs, MDD_OBD_NAME);
- lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs);
-
- if (!lcfg)
- RETURN(-ENOMEM);
-
- rc = class_cleanup(obd, lcfg);
- if (rc)
- GOTO(lcfg_cleanup, rc);
-
- rc = class_detach(obd, lcfg);
- if (rc)
- GOTO(lcfg_cleanup, rc);
- mdd->mdd_md_dev.md_lu_dev.ld_obd = NULL;
-lcfg_cleanup:
- lustre_cfg_free(lcfg);
- RETURN(rc);
-}
}
/* clean PENDING dir */
- rc = mds_cleanup_pending(obd);
- if (rc < 0)
- GOTO(out, rc);
+ if (strcmp(obd->obd_name, MDD_OBD_NAME))
+ rc = mds_cleanup_pending(obd);
+ if (rc < 0)
+ GOTO(out, rc);
/* FIXME Does target_finish_recovery really need this to block? */
/* Notify the LOV, which will in turn call mds_notify for each tgt */
ENTRY;
CDEBUG(D_INFO, "obd %s setup \n", obd->obd_name);
- if (strcmp(obd->obd_name, "mdd_obd"))
+ if (strcmp(obd->obd_name, MDD_OBD_NAME))
RETURN(0);
rc = mds_lov_presetup(mds, lcfg);
rc = mds_postsetup(obd);
obd->obd_async_recov = 0;
+ sema_init(&mds->mds_orphan_recovery_sem, 1);
+ mds->mds_max_mdsize = sizeof(struct lov_mds_md);
+ mds->mds_max_cookiesize = sizeof(struct llog_cookie);
+
RETURN(rc);
}
#include <lustre_lib.h>
#include <lustre_fsfilt.h>
#include <lustre_ver.h>
+#include <dt_object.h>
#include "mds_internal.h"
llog_cat_initialize(obd, mli->md_lov_desc.ld_tgt_count);
up(&mli->md_lov_orphan_recovery_sem);
}
+ CDEBUG(D_CONFIG, "reset llogs idx=%d\n", idx);
+ llog_cat_initialize(obd, mli->md_lov_desc.ld_tgt_count);
#endif
RETURN(rc);
}
RETURN(-ENOTCONN);
}
- mli->md_lov_ops = mlo;
-
OBD_ALLOC(data, sizeof(*data));
if (data == NULL)
RETURN(-ENOMEM);
KEY_MDS_CONN, 0, uuid, NULL);
if (rc != 0)
GOTO(out, rc);
+
#if 0
- /*disable for not support llog in mdd*/
rc = llog_connect(llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT),
mds->mds_lov_desc.ld_tgt_count,
NULL, NULL, uuid);
RETURN(rc);
}
-static int mdt_notify(struct obd_device *obd, struct obd_device *watched,
- enum obd_notify_event ev, void *data)
-{
- struct mdt_device *mdt;
- struct md_device *next;
- struct lu_context ctxt;
- int rc;
- ENTRY;
-
- lu_context_init(&ctxt, LCT_MD_THREAD);
-
- mdt = mdt_dev(obd->obd_lu_dev);
- next = mdt->mdt_child;
-
- lu_context_enter(&ctxt);
- rc = next->md_ops->mdo_notify(&ctxt, next, watched, ev, data);
- lu_context_exit(&ctxt);
-
- lu_context_fini(&ctxt);
- RETURN(rc);
-}
-
static struct obd_ops mdt_obd_device_ops = {
.o_owner = THIS_MODULE,
.o_connect = mdt_obd_connect,
.o_disconnect = mdt_obd_disconnect,
.o_init_export = mdt_init_export, /* By Huang Hua*/
.o_destroy_export = mdt_destroy_export, /* By Huang Hua*/
- .o_notify = mdt_notify,
};
static void mdt_device_free(const struct lu_context *ctx, struct lu_device *d)
{
char *log = mti->mti_svname;
struct llog_handle *llh = NULL;
- char *uuid, *lovname;
+ char *uuid, *lovname, *lmvname;
char mdt_index[5];
int rc = 0;
ENTRY;
RETURN(-ENOMEM);
name_create(log, "-mdtlov", &lovname);
+ name_create(log, "-mdtlmv", &lmvname);
if (mgs_log_is_empty(obd, log)) {
rc = mgs_write_log_lov(obd, fsdb, mti, log, lovname);
}
rc = record_start_log(obd, &llh, log);
rc = record_marker(obd, llh, fsdb, CM_START, log, "add mdt");
rc = record_attach(obd, llh, log, LUSTRE_MDT0_NAME, uuid);
+ /*FIXME: lmvname maybe not right now*/
+ rc = record_mount_opt(obd, llh, log, lovname, lmvname);
rc = record_setup(obd, llh, log, uuid, mdt_index, lovname, 0);
rc = record_marker(obd, llh, fsdb, CM_END, log, "add mdt");
rc = record_end_log(obd, &llh);
#include <obd_class.h>
#include <lustre_log.h>
#include <obd_ost.h>
+#include <lustre_mds.h>
#include <libcfs/list.h>
#include <lvfs.h>
#include <lustre_fsfilt.h>
if (!count)
return (0);
+ if (!strcmp(disk_obd->obd_name, MDD_OBD_NAME)) {
+ struct md_lov_info *mli = &disk_obd->u.mds.mds_lov_info;
+ rc = mli->md_lov_ops->ml_read_catlist(disk_obd, idarray,
+ size, NULL);
+ return (0);
+ }
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
file = filp_open(name, O_RDWR | O_CREAT | O_LARGEFILE, 0700);
if (!file || IS_ERR(file)) {
if (!count)
return (0);
+ if (!strcmp(disk_obd->obd_name, MDD_OBD_NAME)) {
+ struct md_lov_info *mli = &disk_obd->u.mds.mds_lov_info;
+ rc = mli->md_lov_ops->ml_write_catlist(disk_obd, idarray,
+ size, NULL);
+ return (0);
+ }
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
file = filp_open(name, O_RDWR | O_CREAT | O_LARGEFILE, 0700);
if (!file || IS_ERR(file)) {