From: wangdi Date: Thu, 20 Jul 2006 10:19:11 +0000 (+0000) Subject: Branch: b_new_cmd X-Git-Tag: v1_8_0_110~486^2~1378 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=0e62990547709d70bb9ebc0be75c32ae23f836ea;p=fs%2Flustre-release.git Branch: b_new_cmd add mdd obd for llog and lov --- diff --git a/lustre/mdd/Makefile.in b/lustre/mdd/Makefile.in index a2a7249..308761f 100644 --- a/lustre/mdd/Makefile.in +++ b/lustre/mdd/Makefile.in @@ -1,4 +1,4 @@ MODULES := mdd -mdd-objs := mdd_handler.o mdd_lov.o +mdd-objs := mdd_handler.o mdd_lov.o mdd_obd.o @INCLUDE_RULES@ diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index fb7d30e..4090ed1 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -30,6 +30,10 @@ #include #include +#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 { diff --git a/lustre/mdd/mdd_lov.c b/lustre/mdd/mdd_lov.c index 86de339..6d36baa 100644 --- a/lustre/mdd/mdd_lov.c +++ b/lustre/mdd/mdd_lov.c @@ -4,7 +4,7 @@ * linux/mds/mds_lov.c * Lustre Metadata Server (mds) handling of striped file data * - * Copyright (C) 2001-2003 Cluster File Systems, Inc. + * Copyright (C) 2001-2006 Cluster File Systems, Inc. * Author: Peter Braam * wangdi * diff --git a/lustre/mdd/mdd_obd.c b/lustre/mdd/mdd_obd.c new file mode 100644 index 0000000..c56e880 --- /dev/null +++ b/lustre/mdd/mdd_obd.c @@ -0,0 +1,118 @@ +/* -*- 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 + * + * 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 + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#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); +} diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 0082869..fac5b55 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -1786,6 +1786,30 @@ void fsoptions_to_mds_flags(struct mds_obd *mds, char *options) options = ++p; } } +static int mds_lov_presetup (struct mds_obd *mds, struct lustre_cfg *lcfg) +{ + int rc; + ENTRY; + + rc = llog_start_commit_thread(); + if (rc < 0) + RETURN(rc); + + if (lcfg->lcfg_bufcount >= 4 && LUSTRE_CFG_BUFLEN(lcfg, 3) > 0) { + class_uuid_t uuid; + + generate_random_uuid(uuid); + class_uuid_unparse(uuid, &mds->mds_lov_uuid); + + OBD_ALLOC(mds->mds_profile, LUSTRE_CFG_BUFLEN(lcfg, 3)); + if (mds->mds_profile == NULL) + RETURN(-ENOMEM); + + strncpy(mds->mds_profile, lustre_cfg_string(lcfg, 3), + LUSTRE_CFG_BUFLEN(lcfg, 3)); + } + RETURN(rc); +} /* mount the file system (secretly). lustre_cfg parameters are: * 1 = device @@ -1808,7 +1832,7 @@ static int mds_setup(struct obd_device *obd, struct lustre_cfg* lcfg) ENTRY; /* setup 1:/dev/loop/0 2:ext3 3:mdsA 4:errors=remount-ro,iopen_nopriv */ - + CLASSERT(offsetof(struct obd_device, u.obt) == offsetof(struct obd_device, u.mds.mds_obt)); @@ -1889,24 +1913,10 @@ static int mds_setup(struct obd_device *obd, struct lustre_cfg* lcfg) GOTO(err_ns, rc); } - rc = llog_start_commit_thread(); + rc = mds_lov_presetup(mds, lcfg); if (rc < 0) GOTO(err_fs, rc); - if (lcfg->lcfg_bufcount >= 4 && LUSTRE_CFG_BUFLEN(lcfg, 3) > 0) { - class_uuid_t uuid; - - generate_random_uuid(uuid); - class_uuid_unparse(uuid, &mds->mds_lov_uuid); - - OBD_ALLOC(mds->mds_profile, LUSTRE_CFG_BUFLEN(lcfg, 3)); - if (mds->mds_profile == NULL) - GOTO(err_fs, rc = -ENOMEM); - - strncpy(mds->mds_profile, lustre_cfg_string(lcfg, 3), - LUSTRE_CFG_BUFLEN(lcfg, 3)); - } - ptlrpc_init_client(LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL, "mds_ldlm_client", &obd->obd_ldlm_client); obd->obd_replayable = 1; @@ -2663,12 +2673,27 @@ static __attribute__((unused)) void /*__exit*/ mds_exit(void) class_unregister_type(LUSTRE_MDS_NAME); class_unregister_type(LUSTRE_MDT_NAME); } - +/*mds still need lov setup here*/ static int mds_cmd_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { + struct mds_obd *mds = &obd->u.mds; + int rc = 0; ENTRY; - RETURN(0); + CDEBUG(D_INFO, "obd %s setup \n", obd->obd_name); + if (strcmp(obd->obd_name, "mdd_obd")) + RETURN(0); + + rc = mds_lov_presetup(mds, lcfg); + if (rc < 0) + RETURN(rc); + + /* Don't wait for mds_postrecov trying to clear orphans */ + obd->obd_async_recov = 1; + rc = mds_postsetup(obd); + obd->obd_async_recov = 0; + + RETURN(rc); } static int mds_cmd_cleanup(struct obd_device *obd) @@ -2688,6 +2713,12 @@ static struct obd_ops mds_cmd_obd_ops = { .o_owner = THIS_MODULE, .o_setup = mds_cmd_setup, .o_cleanup = mds_cmd_cleanup, + .o_precleanup = mds_precleanup, + .o_create = mds_obd_create, + .o_destroy = mds_obd_destroy, + .o_llog_init = mds_llog_init, + .o_llog_finish = mds_llog_finish, + .o_notify = mds_notify, .o_health_check = mds_cmd_health_check, };