From 01a38e09e5bd2126c819256dda26e055cf6eac71 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 5 Jul 2006 22:20:01 +0000 Subject: [PATCH] Branch b1_5 b=10045 add liblustre support --- lustre/include/liblustre.h | 1 + lustre/liblustre/Makefile.am | 1 + lustre/liblustre/genlib.sh | 1 + lustre/liblustre/llite_lib.c | 55 ++++++++---------- lustre/liblustre/llite_lib.h | 10 ++-- lustre/liblustre/super.c | 11 ++-- lustre/liblustre/tests/sanity.c | 2 +- lustre/mgc/autoMakefile.am | 9 ++- lustre/mgc/libmgc.c | 125 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 172 insertions(+), 43 deletions(-) create mode 100644 lustre/mgc/libmgc.c diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h index 11f47a6..d278d31 100644 --- a/lustre/include/liblustre.h +++ b/lustre/include/liblustre.h @@ -286,6 +286,7 @@ extern int ldlm_init(void); extern int osc_init(void); extern int lov_init(void); extern int mdc_init(void); +extern int mgc_init(void); extern int echo_client_init(void); diff --git a/lustre/liblustre/Makefile.am b/lustre/liblustre/Makefile.am index 872960f..b3df48a 100644 --- a/lustre/liblustre/Makefile.am +++ b/lustre/liblustre/Makefile.am @@ -14,6 +14,7 @@ LUSTRE_LIBS = libllite.a \ $(top_builddir)/lustre/obdecho/libobdecho.a \ $(top_builddir)/lustre/osc/libosc.a \ $(top_builddir)/lustre/mdc/libmdc.a \ + $(top_builddir)/lustre/mgc/libmgc.a \ $(top_builddir)/lustre/ptlrpc/libptlrpc.a \ $(top_builddir)/lustre/obdclass/liblustreclass.a \ $(top_builddir)/lustre/lvfs/liblvfs.a diff --git a/lustre/liblustre/genlib.sh b/lustre/liblustre/genlib.sh index 6d977b3..ec69688 100755 --- a/lustre/liblustre/genlib.sh +++ b/lustre/liblustre/genlib.sh @@ -63,6 +63,7 @@ build_obj_list ../lov liblov.a build_obj_list ../obdecho libobdecho.a build_obj_list ../osc libosc.a build_obj_list ../mdc libmdc.a +build_obj_list ../mgc libmgc.a build_obj_list ../ptlrpc libptlrpc.a build_obj_list ../obdclass liblustreclass.a build_obj_list ../lvfs liblvfs.a diff --git a/lustre/liblustre/llite_lib.c b/lustre/liblustre/llite_lib.c index e222aeb..5e9b6bd 100644 --- a/lustre/liblustre/llite_lib.c +++ b/lustre/liblustre/llite_lib.c @@ -55,27 +55,28 @@ static int lllib_init(void) init_lib_portals() || init_obdclass() || ptlrpc_init() || + mgc_init() || mdc_init() || lov_init() || osc_init()) return -1; - return _sysio_fssw_register("llite", &llu_fssw_ops); + return _sysio_fssw_register("lustre", &llu_fssw_ops); } int liblustre_process_log(struct config_llog_instance *cfg, - char *mdsnid, char *mdsname, char *profile, + char *mgsnid, char *profile, int allow_recov) { struct lustre_cfg_bufs bufs; struct lustre_cfg *lcfg; - char *peer = "MDS_PEER_UUID"; + char *peer = "MGS_UUID"; struct obd_device *obd; - struct lustre_handle mdc_conn = {0, }; + struct lustre_handle mgc_conn = {0, }; struct obd_export *exp; - char *name = "mdc_dev"; + char *name = "mgc_dev"; class_uuid_t uuid; - struct obd_uuid mdc_uuid; + struct obd_uuid mgc_uuid; struct llog_ctxt *ctxt; lnet_nid_t nid = 0; int err, rc = 0; @@ -83,11 +84,11 @@ int liblustre_process_log(struct config_llog_instance *cfg, ENTRY; generate_random_uuid(uuid); - class_uuid_unparse(uuid, &mdc_uuid); + class_uuid_unparse(uuid, &mgc_uuid); - nid = libcfs_str2nid(mdsnid); + nid = libcfs_str2nid(mgsnid); if (nid == LNET_NID_ANY) { - CERROR("Can't parse NID %s\n", mdsnid); + CERROR("Can't parse NID %s\n", mgsnid); RETURN(-EINVAL); } @@ -101,8 +102,8 @@ int liblustre_process_log(struct config_llog_instance *cfg, GOTO(out, rc); lustre_cfg_bufs_reset(&bufs, name); - lustre_cfg_bufs_set_string(&bufs, 1, LUSTRE_MDC_NAME);//FIXME connect to mgc - lustre_cfg_bufs_set_string(&bufs, 2, mdc_uuid.uuid); + lustre_cfg_bufs_set_string(&bufs, 1, LUSTRE_MGC_NAME); + lustre_cfg_bufs_set_string(&bufs, 2, mgc_uuid.uuid); lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs); rc = class_process_config(lcfg); lustre_cfg_free(lcfg); @@ -110,7 +111,7 @@ int liblustre_process_log(struct config_llog_instance *cfg, GOTO(out_del_uuid, rc); lustre_cfg_bufs_reset(&bufs, name); - lustre_cfg_bufs_set_string(&bufs, 1, mdsname); + lustre_cfg_bufs_set_string(&bufs, 1, LUSTRE_MGS_OBDNAME); lustre_cfg_bufs_set_string(&bufs, 2, peer); lcfg = lustre_cfg_new(LCFG_SETUP, &bufs); rc = class_process_config(lcfg); @@ -129,18 +130,14 @@ int liblustre_process_log(struct config_llog_instance *cfg, ocd->ocd_connect_flags = OBD_CONNECT_VERSION; ocd->ocd_version = LUSTRE_VERSION_CODE; - /* Disable initial recovery on this import */ - rc = obd_set_info_async(obd->obd_self_export, - strlen(KEY_INIT_RECOV), KEY_INIT_RECOV, - sizeof(allow_recov), &allow_recov, NULL); - - rc = obd_connect(&mdc_conn, obd, &mdc_uuid, ocd); + rc = obd_connect(&mgc_conn, obd, &mgc_uuid, ocd); if (rc) { - CERROR("cannot connect to %s: rc = %d\n", mdsname, rc); + CERROR("cannot connect to %s at %s: rc = %d\n", + LUSTRE_MGS_OBDNAME, nid, rc); GOTO(out_cleanup, rc); } - exp = class_conn2export(&mdc_conn); + exp = class_conn2export(&mgc_conn); ctxt = exp->exp_obd->obd_llog_ctxt[LLOG_CONFIG_REPL_CTXT]; rc = class_config_parse_llog(ctxt, profile, cfg); @@ -186,9 +183,9 @@ out: RETURN(rc); } -/* parse host:/mdsname/profile string */ -int ll_parse_mount_target(const char *target, char **mdsnid, - char **mdsname, char **profile) +/* parse host:/fsname string */ +int ll_parse_mount_target(const char *target, char **mgsnid, + char **fsname) { static char buf[256]; char *s; @@ -197,17 +194,15 @@ int ll_parse_mount_target(const char *target, char **mdsnid, strncpy(buf, target, 255); if ((s = strchr(buf, ':'))) { - *mdsnid = buf; + *mgsnid = buf; *s = '\0'; while (*++s == '/') ; - *mdsname = s; - if ((s = strchr(*mdsname, '/'))) { - *s = '\0'; - *profile = s + 1; - return 0; - } + sprintf(s + strlen(s), "-client"); + *fsname = s; + + return 0; } return -1; diff --git a/lustre/liblustre/llite_lib.h b/lustre/liblustre/llite_lib.h index d5dfd8c..e09c0ac 100644 --- a/lustre/liblustre/llite_lib.h +++ b/lustre/liblustre/llite_lib.h @@ -172,10 +172,10 @@ struct mount_option_s /* llite_lib.c */ void generate_random_uuid(unsigned char uuid_out[16]); -int liblustre_process_log(struct config_llog_instance *cfg, char *mdsnid, - char *mdsname, char *profile, int allow_recov); -int ll_parse_mount_target(const char *target, char **mdsnid, - char **mdsname, char **profile); +int liblustre_process_log(struct config_llog_instance *cfg, char *mgsnid, + char *profile, int allow_recov); +int ll_parse_mount_target(const char *target, char **mgsnid, + char **fsname); extern struct mount_option_s mount_option; @@ -233,7 +233,7 @@ int llu_mdc_blocking_ast(struct ldlm_lock *lock, /* dir.c */ ssize_t llu_iop_filldirentries(struct inode *ino, _SYSIO_OFF_T *basep, - char *buf, size_t nbytes); + char *buf, size_t nbytes); /* ext2 related */ #define EXT2_NAME_LEN (255) diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 40fe5db..c96b81d 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -1884,7 +1884,7 @@ llu_fsswop_mount(const char *source, struct config_llog_instance cfg; char ll_instance[sizeof(sbi) * 2 + 1]; struct lustre_profile *lprof; - char *zconf_mdsnid, *zconf_mdsname, *zconf_profile; + char *zconf_mgsnid, *zconf_profile; char *osc = NULL, *mdc = NULL; int async = 1, err = -EINVAL; struct obd_connect_data ocd = {0,}; @@ -1892,13 +1892,12 @@ llu_fsswop_mount(const char *source, ENTRY; if (ll_parse_mount_target(source, - &zconf_mdsnid, - &zconf_mdsname, + &zconf_mgsnid, &zconf_profile)) { CERROR("mal-formed target %s\n", source); RETURN(err); } - if (!zconf_mdsnid || !zconf_mdsname || !zconf_profile) { + if (!zconf_mgsnid || !zconf_profile) { printf("Liblustre: invalid target %s\n", source); RETURN(err); } @@ -1918,8 +1917,8 @@ llu_fsswop_mount(const char *source, /* retrive & parse config log */ cfg.cfg_instance = ll_instance; cfg.cfg_uuid = sbi->ll_sb_uuid; - err = liblustre_process_log(&cfg, zconf_mdsnid, zconf_mdsname, - zconf_profile, 1); + cfg.cfg_last_idx = 0; + err = liblustre_process_log(&cfg, zconf_mgsnid, zconf_profile, 1); if (err < 0) { CERROR("Unable to process log: %s\n", zconf_profile); GOTO(out_free, err); diff --git a/lustre/liblustre/tests/sanity.c b/lustre/liblustre/tests/sanity.c index 5c918ad..897eaae 100644 --- a/lustre/liblustre/tests/sanity.c +++ b/lustre/liblustre/tests/sanity.c @@ -1329,7 +1329,7 @@ extern void __liblustre_cleanup_(void); void usage(char *cmd) { printf("\n" - "usage: %s [--only {test}] --target mdsnid:/mdsname/profile\n", + "usage: %s [--only {test}] --target mgsnid:/fsname\n", cmd); printf(" %s --dumpfile dumpfile\n", cmd); exit(-1); diff --git a/lustre/mgc/autoMakefile.am b/lustre/mgc/autoMakefile.am index 2b3a807..36aa65a 100644 --- a/lustre/mgc/autoMakefile.am +++ b/lustre/mgc/autoMakefile.am @@ -1,8 +1,15 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. +# Copyright (C) 2006 Cluster File Systems, Inc. # # This code is issued under the GNU General Public License. # See the file COPYING in this distribution +if LIBLUSTRE +noinst_LIBRARIES = libmgc.a +libmgc_a_SOURCES = libmgc.c +libmgc_a_CPPFLAGS = $(LLCPPFLAGS) +libmgc_a_CFLAGS = $(LLCFLAGS) +endif + if MODULES modulefs_DATA = mgc$(KMODEXT) endif diff --git a/lustre/mgc/libmgc.c b/lustre/mgc/libmgc.c new file mode 100644 index 0000000..cccdde6 --- /dev/null +++ b/lustre/mgc/libmgc.c @@ -0,0 +1,125 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * + * lustre/mgc/mgc_request.c + * Lustre Management Client + * + * Copyright (C) 2006 Cluster File Systems, Inc. + * Author: Nathan Rutman + * + * This file is part of Lustre, http://www.lustre.org + * + * Lustre is free 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. + * + * 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 + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Lustre; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +/* Minimal MGC for liblustre */ + +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif +#define DEBUG_SUBSYSTEM S_MGC + +#include + +#include +#include +#include +#include +#include + + +static int mgc_cleanup(struct obd_device *obd) +{ + struct client_obd *cli = &obd->u.cli; + int rc; + ENTRY; + + LASSERT(cli->cl_mgc_vfsmnt == NULL); + + ptlrpcd_decref(); + + rc = client_obd_cleanup(obd); + RETURN(rc); +} + +static int mgc_setup(struct obd_device *obd, obd_count len, void *buf) +{ + int rc; + ENTRY; + + ptlrpcd_addref(); + + rc = client_obd_setup(obd, len, buf); + if (rc) + GOTO(err_decref, rc); + + rc = obd_llog_init(obd, obd, 0, NULL); + if (rc) { + CERROR("failed to setup llogging subsystems\n"); + GOTO(err_cleanup, rc); + } + + RETURN(rc); + +err_cleanup: + client_obd_cleanup(obd); +err_decref: + ptlrpcd_decref(); + RETURN(rc); +} + +static int mgc_llog_init(struct obd_device *obd, struct obd_device *tgt, + int count, struct llog_catid *logid) +{ + struct llog_ctxt *ctxt; + int rc; + ENTRY; + + rc = llog_setup(obd, LLOG_CONFIG_REPL_CTXT, tgt, 0, NULL, + &llog_client_ops); + if (rc == 0) { + ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT); + ctxt->loc_imp = obd->u.cli.cl_import; + } + + RETURN(rc); +} + +static int mgc_llog_finish(struct obd_device *obd, int count) +{ + int rc; + ENTRY; + + rc = llog_cleanup(llog_get_context(obd, LLOG_CONFIG_REPL_CTXT)); + + RETURN(rc); +} + +struct obd_ops mgc_obd_ops = { + .o_owner = THIS_MODULE, + .o_setup = mgc_setup, + .o_cleanup = mgc_cleanup, + .o_add_conn = client_import_add_conn, + .o_del_conn = client_import_del_conn, + .o_connect = client_connect_import, + .o_disconnect = client_disconnect_export, + .o_llog_init = mgc_llog_init, + .o_llog_finish = mgc_llog_finish, +}; + +int __init mgc_init(void) +{ + return class_register_type(&mgc_obd_ops, NULL, LUSTRE_MGC_NAME); +} + -- 1.8.3.1