From 904ae6e63304c423fd80660465609f9343d3f7c0 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 1 Dec 2005 01:37:04 +0000 Subject: [PATCH] Branch b1_4_mountconf b=8007 add mgc disk setting, start work on mgs llog --- lustre/include/linux/lustre_disk.h | 21 +++- lustre/include/linux/lustre_idl.h | 44 +++----- lustre/include/linux/obd.h | 1 + lustre/ldlm/ldlm_lib.c | 1 + lustre/mds/handler.c | 6 +- lustre/mgc/mgc_request.c | 59 ++++++++--- lustre/mgs/mgs_handler.c | 76 +++++--------- lustre/mgs/mgs_internal.h | 9 +- lustre/mgs/mgs_llog.c | 209 +++++++++++-------------------------- lustre/obdclass/obd_mount.c | 196 +++++++++++++++++++++++----------- lustre/obdfilter/filter.c | 6 +- lustre/ptlrpc/pack_generic.c | 21 ++-- lustre/utils/mkfs_lustre.c | 29 +---- 13 files changed, 325 insertions(+), 353 deletions(-) diff --git a/lustre/include/linux/lustre_disk.h b/lustre/include/linux/lustre_disk.h index a3ee122..2240028 100644 --- a/lustre/include/linux/lustre_disk.h +++ b/lustre/include/linux/lustre_disk.h @@ -90,6 +90,20 @@ struct lustre_disk_data { #define IS_MGMT(data) ((data)->ldd_flags & LDD_F_SV_TYPE_MGMT) #define MT_STR(data) mt_str((data)->ldd_mount_type) +/* Make the mdt/ost server obd name based on the filesystem name */ +static inline void ldd_make_sv_name(struct lustre_disk_data *ldd) +{ + if (IS_MDT(ldd) || IS_OST(ldd)) { + sprintf(ldd->ldd_svname, "%.8s-%s%04x", + ldd->ldd_fsname, + IS_MDT(ldd) ? "MDT" : "OST", + ldd->ldd_svindex); + } else { + sprintf(ldd->ldd_svname, "MGMT"); + } +} + + /****************** mount command *********************/ /* gleaned from the mount command - no persistent info here */ @@ -131,9 +145,6 @@ struct mkfs_opts { int mo_stripe_sz; int mo_stripe_count; int mo_stripe_pattern; - __u16 mo_index; /* stripe index for osts, pool index - for pooled mdts. index will be put - in lr_server_data */ int mo_timeout; /* obd timeout */ }; @@ -218,8 +229,8 @@ struct lustre_mount_info { /* obd_mount.c */ void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb)); void lustre_common_put_super(struct super_block *sb); -struct lustre_mount_info *lustre_get_mount(char *name); -int lustre_put_mount(char *name, struct vfsmount *mnt); +struct lustre_mount_info *server_get_mount(char *name); +int server_put_mount(char *name, struct vfsmount *mnt); int lustre_get_process_log(struct super_block *, char *, struct config_llog_instance *cfg); diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index 7c0f85d..1aaf956 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -942,41 +942,23 @@ typedef enum { #define NAME_MAXLEN 64 #define UUID_MAXLEN NAME_MAXLEN + 5 - -struct mgmt_ost_info { - struct list_head moi_list; - char moi_fullfsname[NAME_MAXLEN]; - char moi_ostname[NAME_MAXLEN]; - char moi_nodename[NAME_MAXLEN]; - char moi_ostuuid[UUID_MAXLEN]; - __u64 moi_nid; /* lnet_nid_t */ - __u32 moi_stripe_index; - __u32 moi_flags; -}; - -extern void lustre_swab_mgmt_ost_info(struct mgmt_ost_info *oinfo); - -struct mgmt_mds_info { - char mmi_fullfsname[64]; - char mmi_mds_name[64]; - char mmi_mds_nodename[64]; - __u64 mmi_nid; - __u32 mmi_index; - __u32 mmi_pattern; /* PATTERN_RAID0, PATTERN_RAID1 */ - __u64 mmi_stripe_size; /* in bytes */ - __u64 mmi_stripe_offset; /* in bytes */ +struct mgmt_target_info { + char mti_fsname[NAME_MAXLEN]; + char mti_targetname[NAME_MAXLEN]; + char mti_nodename[NAME_MAXLEN]; + char mti_uuid[UUID_MAXLEN]; + __u64 mti_nid; /* lnet_nid_t */ //nid list? + __u32 mti_config_ver; + __u32 mti_flags; + __u32 mti_stripe_index; + __u32 mti_stripe_pattern; /* PATTERN_RAID0, PATTERN_RAID1 */ + __u64 mti_stripe_size; /* in bytes */ + __u64 mti_stripe_offset; /* in bytes */ }; -extern void lustre_swab_mgmt_mds_info(struct mgmt_mds_info *oinfo); +extern void lustre_swab_mgmt_target_info(struct mgmt_target_info *oinfo); -struct mgmt_target_info{ - __u32 mti_flags; - union { - struct mgmt_ost_info moi; - struct mgmt_mds_info mmi; - } u; -}; /* * Opcodes for multiple servers. */ diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index 6c60d8b..2967343 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -321,6 +321,7 @@ struct client_obd { struct mdc_rpc_lock *cl_setattr_lock; struct osc_creator cl_oscc; /* mgc datastruct */ + struct semaphore cl_mgc_sem; struct mgc_rpc_lock *cl_mgc_rpc_lock; struct vfsmount *cl_mgc_vfsmnt; struct super_block *cl_mgc_sb; diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 0344aa4..a58eb3b 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -238,6 +238,7 @@ int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf) } sema_init(&cli->cl_sem, 1); + sema_init(&cli->cl_mgc_sem, 1); cli->cl_conn_count = 0; memcpy(server_uuid.uuid, lustre_cfg_buf(lcfg, 2), min_t(unsigned int, LUSTRE_CFG_BUFLEN(lcfg, 2), diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 17e7010..2cea5ea 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -1458,7 +1458,7 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf) if (LUSTRE_CFG_BUFLEN(lcfg, 1) == 0 || LUSTRE_CFG_BUFLEN(lcfg, 2) == 0) RETURN(rc = -EINVAL); - lmi = lustre_get_mount(obd->obd_name); + lmi = server_get_mount(obd->obd_name); if (lmi) { /* We already mounted in lustre_fill_super. lcfg bufs 1, 2, 4 (device, fstype, mount opts) are ignored.*/ @@ -1606,7 +1606,7 @@ err_ops: fsfilt_put_ops(obd->obd_fsops); err_put: if (lmi) { - lustre_put_mount(obd->obd_name, mds->mds_vfsmnt); + server_put_mount(obd->obd_name, mds->mds_vfsmnt); } else { /* old method */ unlock_kernel(); @@ -1816,7 +1816,7 @@ static int mds_cleanup(struct obd_device *obd) upcall_cache_cleanup(mds->mds_group_hash); mds->mds_group_hash = NULL; - must_put = lustre_put_mount(obd->obd_name, mds->mds_vfsmnt); + must_put = server_put_mount(obd->obd_name, mds->mds_vfsmnt); /* must_put is for old method (l_p_m returns non-0 on err) */ /* We can only unlock kernel if we are in the context of sys_ioctl, diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index cf1408e..551d408 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -50,10 +50,10 @@ /* Get index and add to config llog, depending on flags */ -int mgc_target_add(struct obd_export *exp, struct mgmt_ost_info *moi) +int mgc_target_add(struct obd_export *exp, struct mgmt_target_info *moi) { struct ptlrpc_request *req; - struct mgmt_ost_info *req_moi, *rep_moi; + struct mgmt_target_info *req_moi, *rep_moi; int size = sizeof(*req_moi); int rep_size = sizeof(*moi); int rc; @@ -73,7 +73,7 @@ int mgc_target_add(struct obd_export *exp, struct mgmt_ost_info *moi) if (!rc) { int index; rep_moi = lustre_swab_repbuf(req, 0, sizeof(*rep_moi), - lustre_swab_mgmt_ost_info); + lustre_swab_mgmt_target_info); index = rep_moi->moi_stripe_index; if (index != moi->moi_stripe_index) { CERROR ("OST ADD failed. rc=%d\n", index); @@ -89,10 +89,10 @@ out: EXPORT_SYMBOL(mgc_target_add); /* Remove from config llog */ -int mgc_target_del(struct obd_export *exp, struct mgmt_ost_info *moi) +int mgc_target_del(struct obd_export *exp, struct mgmt_target_info *moi) { struct ptlrpc_request *req; - struct mgmt_ost_info *req_moi, *rep_moi; + struct mgmt_target_info *req_moi, *rep_moi; int size = sizeof(*req_moi); int rc; ENTRY; @@ -109,7 +109,7 @@ int mgc_target_del(struct obd_export *exp, struct mgmt_ost_info *moi) if (!rc) { int index; rep_moi = lustre_swab_repbuf(req, 0, sizeof(*rep_moi), - lustre_swab_mgmt_ost_info); + lustre_swab_mgmt_target_info); index = rep_moi->moi_stripe_index; if (index != moi->moi_stripe_index) { CERROR ("OST DEL failed. rc=%d\n", index); @@ -134,6 +134,11 @@ static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb, int err = 0; LASSERT(lsi); + LASSERT(lsi->lsi_srv_mnt == mnt); + + /* The mgc fs exclusion sem. Only one fs can be setup at a time. + Maybe just overload the cl_sem? */ + down(&cli->cl_mgc_sem); obd->obd_fsops = fsfilt_get_ops(MT_STR(lsi->lsi_ldd)); if (IS_ERR(obd->obd_fsops)) { @@ -187,15 +192,20 @@ static int mgc_fs_cleanup(struct obd_device *obd) pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); } - rc = lustre_put_mount(obd->obd_name, cli->cl_mgc_vfsmnt); + /* never got mount + rc = server_put_mount(obd->obd_name, cli->cl_mgc_vfsmnt); if (rc) CERROR("mount_put failed %d\n", rc); + */ cli->cl_mgc_vfsmnt = NULL; cli->cl_mgc_sb = NULL; if (obd->obd_fsops) fsfilt_put_ops(obd->obd_fsops); + + up(&cli->cl_mgc_sem); + return(rc); } @@ -206,10 +216,7 @@ static int mgc_cleanup(struct obd_device *obd) //lprocfs_obd_cleanup(obd); - if (cli->cl_mgc_vfsmnt) { - /* if we're a server, eg. something's mounted */ - mgc_fs_cleanup(obd); - } + LASSERT(cli->cl_mgc_vfsmnt == NULL); rc = obd_llog_finish(obd, 0); if (rc != 0) @@ -382,14 +389,38 @@ int mgc_set_info(struct obd_export *exp, obd_count keylen, /* Hack alert */ if (keylen == strlen("register") && memcmp(key, "register", keylen) == 0) { - struct mgmt_ost_info *moi; - if (vallen != sizeof(struct mgmt_ost_info)) + struct mgmt_target_info *moi; + if (vallen != sizeof(struct mgmt_target_info)) RETURN(-EINVAL); - moi = (struct mgmt_ost_info *)val; + moi = (struct mgmt_target_info *)val; CERROR("register %s %#x\n", moi->moi_ostname, moi->moi_flags); rc = mgc_target_add(exp, moi); RETURN(rc); } + if (keylen == strlen("set_fs") && + memcmp(key, "set_fs", keylen) == 0) { + struct super_block *sb = (struct super_block *)val; + struct lustre_sb_info *lsi; + if (vallen != sizeof(struct super_block)) + RETURN(-EINVAL); + lsi = s2lsi(sb); + rc = mgc_fs_setup(exp->exp_obd, sb, lsi->lsi_srv_mnt); + if (rc) { + CERROR("set_fs got %d\n", rc); + } + RETURN(rc); + } + if (keylen == strlen("clear_fs") && + memcmp(key, "clear_fs", keylen) == 0) { + if (vallen != 0) + RETURN(-EINVAL); + rc = mgc_fs_cleanup(exp->exp_obd); + if (rc) { + CERROR("clear_fs got %d\n", rc); + } + RETURN(rc); + } + RETURN(rc); } diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index b26cad5..7d17a0a 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -132,7 +132,7 @@ static int mgs_setup(struct obd_device *obd, obd_count len, void *buf) CDEBUG(D_CONFIG, "Starting MGS\n"); - lmi = lustre_get_mount(obd->obd_name); + lmi = server_get_mount(obd->obd_name); if (!lmi) RETURN(rc = -EINVAL); @@ -185,7 +185,7 @@ err_ns: err_ops: fsfilt_put_ops(obd->obd_fsops); err_put: - lustre_put_mount(obd->obd_name, mgs->mgs_vfsmnt); + server_put_mount(obd->obd_name, mgs->mgs_vfsmnt); mgs->mgs_sb = 0; return rc; } @@ -228,7 +228,7 @@ static int mgs_cleanup(struct obd_device *obd) //mgs_fs_cleanup(obd); - lustre_put_mount(obd->obd_name, mgs->mgs_vfsmnt); + server_put_mount(obd->obd_name, mgs->mgs_vfsmnt); mgs->mgs_sb = NULL; ldlm_namespace_free(obd->obd_namespace, obd->obd_force); @@ -249,44 +249,42 @@ static int mgs_cleanup(struct obd_device *obd) RETURN(0); } -static int mgmt_handle_target_add(struct ptlrpc_request *req) +static int mgs_handle_target_add(struct ptlrpc_request *req) { struct obd_device *obd = &req->rq_export->exp_obd; struct mgs_obd *mgs = &obd->u.mgs; - struct mgmt_ost_info *req_moi, *moi, *rep_moi; - int rep_size = sizeof(*moi); + struct mgmt_target_info *req_mti, *mti, *rep_mti; + int rep_size = sizeof(*mti); int index, rc; - OBD_ALLOC(moi, sizeof(*moi)); - if (!moi) + OBD_ALLOC(mti, sizeof(*mti)); + if (!mti) GOTO(out, rc = -ENOMEM); - req_moi = lustre_swab_reqbuf(req, 0, sizeof(*moi), - lustre_swab_mgmt_ost_info); - memcpy(moi, req_moi, sizeof(*moi)); + req_mti = lustre_swab_reqbuf(req, 0, sizeof(*mti), + lustre_swab_mgmt_target_info); + memcpy(mti, req_mti, sizeof(*mti)); - /* NEED_INDEX implies FIRST_START, but not vice-versa */ - if (moi->moi_flags & LDD_F_NEED_INDEX) { - rc = mgs_get_index(moi); + /* NEED_INDEX implies NEED_REGISTER, but not vice-versa */ + if (mti->mti_flags & LDD_F_NEED_INDEX) { + rc = mgs_get_index(mti); // rc = mgmt_handle_first_connect(req); } - if (moi->moi_flags & LDD_F_SV_TYPE_MDT) { - rc = llog_add_mds(obd, moi); + if (mti->mti_flags & LDD_F_SV_TYPE_MDT) { + rc = llog_add_mds(obd, mti); } out: lustre_pack_reply(req, 1, &rep_size, NULL); - rep_moi = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*rep_moi)); - memcpy(rep_moi, moi, sizeof(*rep_moi)); + rep_mti = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*rep_mti)); + memcpy(rep_mti, mti, sizeof(*rep_mti)); if (rc) - rep_moi->moi_stripe_index = rc; + rep_mti->mti_stripe_index = rc; return rc; } int mgs_handle(struct ptlrpc_request *req) { - struct mgs_obd *mgs = NULL; /* quell gcc overwarning */ - struct obd_device *obd = NULL; int fail = OBD_FAIL_MGMT_ALL_REPLY_NET; int rc = 0; ENTRY; @@ -294,7 +292,6 @@ int mgs_handle(struct ptlrpc_request *req) OBD_FAIL_RETURN(OBD_FAIL_MGMT_ALL_REQUEST_NET | OBD_FAIL_ONCE, 0); LASSERT(current->journal_info == NULL); - /* XXX identical to MDS */ if (req->rq_reqmsg->opc != MGMT_CONNECT) { if (req->rq_export == NULL) { CERROR("lustre_mgs: operation %d on unconnected MGS\n", @@ -302,8 +299,6 @@ int mgs_handle(struct ptlrpc_request *req) req->rq_status = -ENOTCONN; GOTO(out, rc = -ENOTCONN); } - obd = req->rq_export->exp_obd; - mgs = &obd->u.mgs; } switch (req->rq_reqmsg->opc) { @@ -311,13 +306,7 @@ int mgs_handle(struct ptlrpc_request *req) DEBUG_REQ(D_INODE, req, "connect"); OBD_FAIL_RETURN(OBD_FAIL_MGMT_CONNECT_NET, 0); rc = target_handle_connect(req, mgs_handle); - if (!rc) { - /* Now that we have an export, set mgs. */ - obd = req->rq_export->exp_obd; - mgs = mgs_req2mgs(req); - } break; - case MGMT_DISCONNECT: DEBUG_REQ(D_INODE, req, "disconnect"); OBD_FAIL_RETURN(OBD_FAIL_MGMT_DISCONNECT_NET, 0); @@ -325,6 +314,15 @@ int mgs_handle(struct ptlrpc_request *req) req->rq_status = rc; /* superfluous? */ break; + case MGMT_TARGET_ADD: + CDEBUG(D_INODE, "target add\n"); + rc = mgs_handle_target_add(req); + break; + case MGMT_TARGET_DEL: + CDEBUG(D_INODE, "target del\n"); + //rc = mgs_handle_target_del(req); + break; + case LDLM_ENQUEUE: DEBUG_REQ(D_INODE, req, "enqueue"); OBD_FAIL_RETURN(OBD_FAIL_LDLM_ENQUEUE, 0); @@ -350,23 +348,7 @@ int mgs_handle(struct ptlrpc_request *req) OBD_FAIL_RETURN(OBD_FAIL_OBD_LOG_CANCEL_NET, 0); rc = -ENOTSUPP; /* la la la */ break; - // case MGMT_FIRST_CONNECT: - // CDEBUG(D_INODE, "server connect at first time\n"); - // OBD_FAIL_RETURN(OBD_FAIL_MGMT_FIRST_CONNECT, 0); - // rc = mgmt_handle_first_connect(req); -// break; - case MGMT_TARGET_ADD: - CDEBUG(D_INODE, "target add\n"); - rc = mgmt_handle_target_add(req); - break; - case MGMT_TARGET_DEL: - CDEBUG(D_INODE, "target del\n"); -// rc = mgmt_handle_target_del(req); - break; -// case MGMT_MDS_ADD: -// CDEBUG(D_INODE, "mds add\n"); -// rc = mgmt_handle_mds_add(req); -// break; + case LLOG_ORIGIN_HANDLE_CREATE: DEBUG_REQ(D_INODE, req, "llog_init"); OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0); diff --git a/lustre/mgs/mgs_internal.h b/lustre/mgs/mgs_internal.h index 1a73415..9733fba 100644 --- a/lustre/mgs/mgs_internal.h +++ b/lustre/mgs/mgs_internal.h @@ -11,13 +11,6 @@ extern struct lvfs_callback_ops mgs_lvfs_ops; -static inline struct mgs_obd *mgs_req2mgs(struct ptlrpc_request *req) -{ - return &req->rq_export->exp_obd->u.mgs; -} +int mgs_get_index(struct obd_device *obd, mgmt_target_info *mti); -extern int mgmt_handle_first_connect(struct ptlrpc_request *req); -extern int mgmt_handle_mds_add(struct ptlrpc_request *req); -extern int mgmt_handle_ost_add(struct ptlrpc_request *req); -extern int mgmt_handle_ost_del(struct ptlrpc_request *req); #endif diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 9deda3e..599d460 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -142,8 +142,7 @@ static int get_ost_number(void *index_map, int map_len) return num; } -int mgs_get_index(struct obd_device *obd, char *full_fsname, - int disk_type, int *new_index) +int mgs_get_index(struct obd_device *obd, mgmt_target_info *mti) { struct mgs_obd *mgs = &obd->u.mgs; struct system_db *db; @@ -152,8 +151,8 @@ int mgs_get_index(struct obd_device *obd, char *full_fsname, list_for_each(tmp, &mgs->mgs_system_db_list) { db = list_entry(tmp, struct system_db, db_list); - if (!strcmp(db->fsname, full_fsname)) { - if (disk_type & LDD_F_SV_TYPE_OST) + if (strcmp(db->fsname, mti->mti_fsname) == 0) { + if (mti->mti_flags & LDD_F_SV_TYPE_OST) *new_index = next_ost_index(db->index_map, 4096); else *new_index = 1; /*FIXME*/ @@ -164,10 +163,10 @@ int mgs_get_index(struct obd_device *obd, char *full_fsname, OBD_ALLOC(db, sizeof(*db)); if (!db) return -ENOMEM; - strcpy(db->fsname, full_fsname); + strcpy(db->fsname, mti->mti_fsname); INIT_LIST_HEAD(&db->db_list); INIT_LIST_HEAD(&db->ost_infos); - rc = get_index_map_from_llog(obd, full_fsname, db->index_map); + rc = get_index_map_from_llog(obd, mti->mti_fsname, db->index_map); if (rc) GOTO(clean, rc); spin_lock(&mgs->mgs_system_db_lock); @@ -182,7 +181,6 @@ clean: OBD_FREE(db, sizeof(*db)); goto out; } -EXPORT_SYMBOL(mgs_get_index); static int mgs_do_record(struct obd_device *obd, struct llog_handle *llh, void *cfg_buf) @@ -386,18 +384,20 @@ static int mgs_clear_record(struct obd_device *obd, } static int mgs_write_basic_llog(struct obd_device *obd, - struct mgmt_mds_info *mmi) + struct mgmt_target_info *mti) { int rc = 0; CERROR("New basic LLOG.\n"); /*FIXME: add soon*/ return rc; } -static int mgs_write_mds_llog(struct obd_device *obd, struct mgmt_mds_info *mmi) + +static int mgs_write_target_llog(struct obd_device *obd, + struct mgmt_target_info *mti) { struct mgs_open_llog *mol; struct llog_handle *llh; struct list_head *tmp; - char *name = mmi->mmi_fullfsname; + char *name = mti->mti_fsname; struct lov_desc *lovdesc; char lov_name[64]; char uuid[64]; @@ -410,9 +410,9 @@ static int mgs_write_mds_llog(struct obd_device *obd, struct mgmt_mds_info *mmi) OBD_ALLOC(lovdesc, sizeof(*lovdesc)); if (lovdesc == NULL) GOTO(cleanup, rc = -ENOMEM); - lovdesc->ld_pattern = mmi->mmi_pattern; - lovdesc->ld_default_stripe_size = mmi->mmi_stripe_size; - lovdesc->ld_default_stripe_offset = mmi->mmi_stripe_offset; + lovdesc->ld_pattern = mti->mti_stripe_pattern; + lovdesc->ld_default_stripe_size = mti->mti_stripe_size; + lovdesc->ld_default_stripe_offset = mti->mti_stripe_offset; rc = mgs_clear_record(obd, llh, name); if (rc) { @@ -427,8 +427,8 @@ static int mgs_write_mds_llog(struct obd_device *obd, struct mgmt_mds_info *mmi) } /* the same uuid for lov and osc */ - sprintf(uuid, "%s_lov_UUID", mmi->mmi_mds_name); - sprintf(lov_name, "lov_%s", mmi->mmi_mds_name); + sprintf(uuid, "%s_lov_UUID", mti->mti_fsname); + sprintf(lov_name, "lov_%s", mti->mti_fsname); sprintf((char*)lovdesc->ld_uuid.uuid, "%s_UUID", lov_name); rc = record_attach(obd, llh, lov_name, "lov", uuid); @@ -449,15 +449,15 @@ static int mgs_write_mds_llog(struct obd_device *obd, struct mgmt_mds_info *mmi) char osc_name[64]; char index[16]; char *setup_argv[2]; - struct mgmt_ost_info *oinfo; + struct mgmt_target_info *oinfo; - oinfo = list_entry(tmp, struct mgmt_ost_info, moi_list); + oinfo = list_entry(tmp, struct mgmt_target_info, mti_list); - sprintf(ost_node_uuid, "%s_UUID", oinfo->moi_nodename); + sprintf(ost_node_uuid, "%s_UUID", oinfo->mti_nodename); sprintf(osc_name,"OSC_%s_%s_%s", - db->mds_nodename, oinfo->moi_ostname, db->mds_name); + db->mds_nodename, oinfo->mti_ostname, db->mds_name); - rc = record_add_uuid(obd, llh, oinfo->moi_nid, ost_node_uuid); + rc = record_add_uuid(obd, llh, oinfo->mti_nid, ost_node_uuid); if (rc) { CERROR("failed to record log(add_uuid) %s: %d\n", name, rc); @@ -471,7 +471,7 @@ static int mgs_write_mds_llog(struct obd_device *obd, struct mgmt_mds_info *mmi) RETURN(rc); } - setup_argv[0] = oinfo->moi_ostuuid; + setup_argv[0] = oinfo->mti_ostuuid; setup_argv[1] = ost_node_uuid; rc = record_setup(obd, llh, osc_name, 2, setup_argv); if (rc) { @@ -480,9 +480,9 @@ static int mgs_write_mds_llog(struct obd_device *obd, struct mgmt_mds_info *mmi) RETURN(rc); } - sprintf(index, "%d", oinfo->moi_stripe_index); + sprintf(index, "%d", oinfo->mti_stripe_index); rc = record_lov_modify_tgts(obd, llh, lov_name, "add", - oinfo->moi_ostuuid, index, "1"); + oinfo->mti_ostuuid, index, "1"); if (rc) { CERROR("failed to record log(lov_modify_tgts) %s: %d\n", name, rc); @@ -490,7 +490,7 @@ static int mgs_write_mds_llog(struct obd_device *obd, struct mgmt_mds_info *mmi) } } #endif - rc = record_mount_point(obd, llh, mmi->mmi_mds_name, lov_name, NULL); + rc = record_mount_point(obd, llh, mti->mti_target_name, lov_name, NULL); if (rc) { CERROR("failed to record log(lov_modify_tgts) %s: %d\n", name, rc); @@ -567,15 +567,15 @@ static int mgs_write_client_llog(struct obd_device *obd, char* name) char ost_node_uuid[64]; char osc_name[64]; char index[16]; - struct mgmt_ost_info *oinfo; + struct mgmt_target_info *oinfo; - oinfo = list_entry(tmp, struct mgmt_ost_info, moi_list); + oinfo = list_entry(tmp, struct mgmt_target_info, mti_list); - sprintf(ost_node_uuid, "%s_UUID", oinfo->moi_nodename); + sprintf(ost_node_uuid, "%s_UUID", oinfo->mti_nodename); sprintf(osc_name, "OSC_%s_%s_MNT_client", - db->mds_nodename, oinfo->moi_ostname); + db->mds_nodename, oinfo->mti_ostname); - rc = record_add_uuid(obd, llh, oinfo->moi_nid, ost_node_uuid); + rc = record_add_uuid(obd, llh, oinfo->mti_nid, ost_node_uuid); if (rc) { CERROR("failed to record log(add_uuid) %s: %d\n", name, rc); @@ -589,7 +589,7 @@ static int mgs_write_client_llog(struct obd_device *obd, char* name) RETURN(rc); } - setup_argv[0] = oinfo->moi_ostuuid; + setup_argv[0] = oinfo->mti_ostuuid; setup_argv[1] = ost_node_uuid; rc = record_setup(obd, llh, osc_name, 2, setup_argv); if (rc) { @@ -598,9 +598,9 @@ static int mgs_write_client_llog(struct obd_device *obd, char* name) RETURN(rc); } - sprintf(index, "%d", oinfo->moi_stripe_index); + sprintf(index, "%d", oinfo->mti_stripe_index); rc = record_lov_modify_tgts(obd, llh, lov_name, "add", - oinfo->moi_ostuuid, index, "1"); + oinfo->mti_ostuuid, index, "1"); if (rc) { CERROR("failed to record log(lov_modify_tgts) %s: %d\n", name, rc); @@ -737,58 +737,7 @@ out: return rc; } -int mgmt_handle_first_connect(struct ptlrpc_request *req) -{ - struct obd_export *exp = req->rq_export; - struct obd_device *obd = exp->exp_obd; - struct mgs_obd *mgs = &obd->u.mgs; - __u32 *disk_type; - char *full_fsname, *node_name; - int rep_size = sizeof(int); - int new_index, *rep_index; - int rc; - - disk_type = lustre_swab_reqbuf(req, 0, sizeof(*disk_type), - __swab32s); - full_fsname = lustre_swab_reqbuf(req, 1, NAME_MAXLEN, NULL); - node_name = lustre_swab_reqbuf(req, 2, NAME_MAXLEN, NULL); - - if (*disk_type & LDD_F_SV_TYPE_MDT) { - CDEBUG(D_INODE, - "New MDS Server belong to FILESYSTEM[/POOL]%s\n", - full_fsname); - } - else if (*disk_type & LDD_F_SV_TYPE_OST) { - CDEBUG(D_INODE, - "New OST Server belong to FILESYSTEM[/POOL]%s\n", - full_fsname); - } - else { - CERROR("Wrong disk type register.\n"); - GOTO(out, rc = -EFAULT); - } - - rc = build_llog_dir(obd, full_fsname); - if (rc) { - CERROR("Can not build llog dir.\n"); - GOTO(out, rc); - } - - rc = mgs_get_index(obd, full_fsname, *disk_type, &new_index); - if (rc) { - CERROR("Can not get index for the new server.\n" ); - new_index = rc; - } - -out: - lustre_pack_reply(req, 1, &rep_size, NULL); - rep_index = lustre_msg_buf(req->rq_repmsg, 0, sizeof(int)); - *rep_index = new_index; - - return rc; -} - -int llog_add_ost(struct obd_device *obd, struct mgmt_ost_info *moi) +int llog_add_ost(struct obd_device *obd, struct mgmt_target_info *mti) { struct mgs_obd *mgs = &obd->u.mgs; struct llog_handle *llh; @@ -805,7 +754,7 @@ int llog_add_ost(struct obd_device *obd, struct mgmt_ost_info *moi) list_for_each(tmp, &mgs->mgs_system_db_list) { struct system_db *tmp_db; tmp_db = list_entry(tmp, struct system_db, db_list); - if (!strcmp(tmp_db->fsname, moi->moi_fullfsname)) { + if (!strcmp(tmp_db->fsname, mti->mti_fsname)) { db = tmp_db; break; } @@ -822,24 +771,24 @@ int llog_add_ost(struct obd_device *obd, struct mgmt_ost_info *moi) */ /*First phase: writing mds log */ - sprintf(logname, "%s/mds1", moi->moi_fullfsname); + sprintf(logname, "%s/mds1", mti->mti_fullfsname); rc = mgs_start_record(obd, llh, logname); if (rc) { CERROR("failed to record log %s: %d\n", logname, rc); GOTO(out, rc); } - sprintf(ost_node_uuid, "%s_UUID", moi->moi_nodename); + sprintf(ost_node_uuid, "%s_UUID", mti->mti_nodename); sprintf(osc_name, "OSC_%s_%s_MNT_client", - db->fsname, moi->moi_ostname); + db->fsname, mti->mti_ostname); - rc = record_add_uuid(obd, llh, moi->moi_nid, ost_node_uuid); + rc = record_add_uuid(obd, llh, mti->mti_nid, ost_node_uuid); if (rc) { CERROR("failed to record log(add_uuid) %s: %d\n", logname, rc); GOTO(out, rc); } - sprintf(uuid, "%s_lov_UUID", moi->moi_fullfsname); + sprintf(uuid, "%s_lov_UUID", mti->mti_fullfsname); rc = record_attach(obd, llh, osc_name, "osc", uuid); if (rc) { @@ -848,7 +797,7 @@ int llog_add_ost(struct obd_device *obd, struct mgmt_ost_info *moi) GOTO(out, rc); } - setup_argv[0] = moi->moi_ostuuid; + setup_argv[0] = mti->mti_ostuuid; setup_argv[1] = ost_node_uuid; rc = record_setup(obd, llh, osc_name, 2, setup_argv); if (rc) { @@ -857,9 +806,9 @@ int llog_add_ost(struct obd_device *obd, struct mgmt_ost_info *moi) GOTO(out, rc); } - sprintf(index, "%d", moi->moi_stripe_index); + sprintf(index, "%d", mti->mti_stripe_index); rc = record_lov_modify_tgts(obd, llh, lov_name, "add", - moi->moi_ostuuid, index, "1"); + mti->mti_ostuuid, index, "1"); if (rc) { CERROR("failed to record log(lov_modify_tgts) %s: %d\n", logname, rc); @@ -873,7 +822,7 @@ int llog_add_ost(struct obd_device *obd, struct mgmt_ost_info *moi) } /*Second Phase : writing client llog */ - sprintf(logname, "%s/client", moi->moi_fullfsname); + sprintf(logname, "%s/client", mti->mti_fullfsname); rc = mgs_start_record(obd, llh, logname); if (rc) { @@ -881,11 +830,11 @@ int llog_add_ost(struct obd_device *obd, struct mgmt_ost_info *moi) GOTO(out, rc); } - sprintf(ost_node_uuid, "%s_UUID", moi->moi_nodename); + sprintf(ost_node_uuid, "%s_UUID", mti->mti_nodename); sprintf(osc_name, "OSC_%s_%s_MNT_client", - db->fsname, moi->moi_ostname); + db->fsname, mti->mti_ostname); - rc = record_add_uuid(obd, llh, moi->moi_nid, ost_node_uuid); + rc = record_add_uuid(obd, llh, mti->mti_nid, ost_node_uuid); if (rc) { CERROR("failed to record log(add_uuid) %s: %d\n", logname, rc); @@ -899,7 +848,7 @@ int llog_add_ost(struct obd_device *obd, struct mgmt_ost_info *moi) GOTO(out, rc); } - setup_argv[0] = moi->moi_ostuuid; + setup_argv[0] = mti->mti_ostuuid; setup_argv[1] = ost_node_uuid; rc = record_setup(obd, llh, osc_name, 2, setup_argv); if (rc) { @@ -908,9 +857,9 @@ int llog_add_ost(struct obd_device *obd, struct mgmt_ost_info *moi) GOTO(out, rc); } - sprintf(index, "%d", moi->moi_stripe_index); + sprintf(index, "%d", mti->mti_stripe_index); rc = record_lov_modify_tgts(obd, llh, lov_name, "add", - moi->moi_ostuuid, index, "1"); + mti->mti_ostuuid, index, "1"); if (rc) { CERROR("failed to record log(lov_modify_tgts) %s: %d\n", logname, rc); @@ -928,7 +877,7 @@ out: } EXPORT_SYMBOL(llog_add_ost); -int llog_add_mds(struct obd_device *obd, struct mgmt_mds_info *mmi) +int llog_add_mds(struct obd_device *obd, struct mgmt_target_info *mti) { struct mgs_obd *mgs = &obd->u.mgs; struct llog_handle *llh; @@ -946,7 +895,7 @@ int llog_add_mds(struct obd_device *obd, struct mgmt_mds_info *mmi) list_for_each(tmp, &mgs->mgs_system_db_list) { struct system_db *tmp_db; tmp_db = list_entry(tmp, struct system_db, db_list); - if (!strcmp(tmp_db->fsname, mmi->mmi_fullfsname)) { + if (!strcmp(tmp_db->fsname, mti->mti_fullfsname)) { db = tmp_db; break; } @@ -963,9 +912,9 @@ int llog_add_mds(struct obd_device *obd, struct mgmt_mds_info *mmi) GOTO(out, rc = -ENOMEM); ld->ld_tgt_count = get_ost_number(db->index_map, 4096); - ld->ld_default_stripe_count = mmi->mmi_stripe_size; - ld->ld_pattern = mmi->mmi_pattern; - ld->ld_default_stripe_offset = mmi->mmi_stripe_offset; + ld->ld_default_stripe_count = mti->mti_stripe_size; + ld->ld_pattern = mti->mti_stripe_pattern; + ld->ld_default_stripe_offset = mti->mti_stripe_offset; sprintf((char*)ld->ld_uuid.uuid, "lov1_UUID"); /* Two phases: 1. writing mds log. @@ -973,7 +922,7 @@ int llog_add_mds(struct obd_device *obd, struct mgmt_mds_info *mmi) */ /*First phase: writing mds log */ - sprintf(logname, "%s/mds1", mmi->mmi_fullfsname); + sprintf(logname, "%s/mds1", mti->mti_fullfsname); rc = mgs_start_record(obd, llh, logname); if (rc) { @@ -982,7 +931,7 @@ int llog_add_mds(struct obd_device *obd, struct mgmt_mds_info *mmi) } /* the same uuid for lov and osc */ - sprintf(uuid, "%s_lov_UUID", mmi->mmi_mds_name); + sprintf(uuid, "%s_lov_UUID", mti->mti_target_name); sprintf(lov_name, "lov_client"); rc = record_attach(obd, llh, lov_name, "lov", uuid); @@ -997,7 +946,7 @@ int llog_add_mds(struct obd_device *obd, struct mgmt_mds_info *mmi) GOTO(out, rc);; } - rc = record_mount_point(obd, llh, mmi->mmi_mds_name, lov_name, NULL); + rc = record_mount_point(obd, llh, mti->mti_target_name, lov_name, NULL); if (rc) { CERROR("failed to record log(mount_point) %s: %d\n", logname, rc); @@ -1020,7 +969,7 @@ int llog_add_mds(struct obd_device *obd, struct mgmt_mds_info *mmi) } /* the same uuid for lov and osc */ - sprintf(uuid, "%s_lov_UUID", mmi->mmi_mds_name); + sprintf(uuid, "%s_lov_UUID", mti->mti_target_name); sprintf(lov_name, "lov_client"); rc = record_attach(obd, llh, lov_name, "lov", uuid); @@ -1036,8 +985,8 @@ int llog_add_mds(struct obd_device *obd, struct mgmt_mds_info *mmi) GOTO(out, rc);; } - sprintf(mds_node_uuid, "%s_UUID", mmi->mmi_mds_nodename); - rc = record_add_uuid(obd, llh, mmi->mmi_nid, mds_node_uuid); + sprintf(mds_node_uuid, "%s_UUID", mti->mti_target_nodename); + rc = record_add_uuid(obd, llh, mti->mti_nid, mds_node_uuid); if (rc) { CERROR("failed to record log(add uuid) %s: %d\n", logname, rc); @@ -1045,8 +994,8 @@ int llog_add_mds(struct obd_device *obd, struct mgmt_mds_info *mmi) } sprintf(mdc_name, "MDC_%s_%s_MNT_client", - mmi->mmi_mds_nodename, mmi->mmi_mds_name); - sprintf(mdc_uuid, "MDC_%s_UUID", mmi->mmi_fullfsname); + mti->mti_target_nodename, mti->mti_target_name); + sprintf(mdc_uuid, "MDC_%s_UUID", mti->mti_fullfsname); rc = record_attach(obd, llh, mdc_name, "mdc", mdc_uuid); if (rc) { @@ -1055,7 +1004,7 @@ int llog_add_mds(struct obd_device *obd, struct mgmt_mds_info *mmi) RETURN(rc); } - sprintf(setup_argv[0],"%s_UUID", mmi->mmi_mds_name); + sprintf(setup_argv[0],"%s_UUID", mti->mti_mds_name); setup_argv[1] = mds_node_uuid; rc = record_setup(obd, llh, mdc_name, 2, setup_argv); if (rc) { @@ -1085,33 +1034,6 @@ out: } EXPORT_SYMBOL(llog_add_mds); -int mgmt_handle_mds_add(struct ptlrpc_request *req) -{ - struct obd_device *obd = &req->rq_export->exp_obd; - struct mgs_obd *mgs = &obd->u.mgs; - struct mgmt_mds_info *req_mmi, *mmi, *rep_mmi; - int rep_size = sizeof(*mmi); - int index, rc; - - OBD_ALLOC(mmi, sizeof(*mmi)); - if (!mmi) - GOTO(out, rc = -ENOMEM); - req_mmi = lustre_swab_reqbuf(req, 0, sizeof(*mmi), - lustre_swab_mgmt_mds_info); - memcpy(mmi, req_mmi, sizeof(*mmi)); - - rc = llog_add_mds(obd, mmi); -out: - lustre_pack_reply(req, 1, &rep_size, NULL); - rep_mmi = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*rep_mmi)); - memcpy(rep_mmi, mmi, sizeof(*rep_mmi)); - if (rc) - rep_mmi->mmi_index = rc; - return rc; -} -EXPORT_SYMBOL(mgmt_handle_mds_add); - - int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg) { @@ -1281,11 +1203,6 @@ int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len, RETURN(rc); } - case OBD_IOC_ABORT_RECOVERY: - CERROR("aborting recovery for device %s\n", obd->obd_name); - target_abort_recovery(obd); - RETURN(0); - default: CDEBUG(D_INFO, "unknown command %x\n", cmd); RETURN(-EINVAL); diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 88d91dc..4b11722 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -43,7 +43,7 @@ static int (*client_fill_super)(struct super_block *sb) = NULL; DECLARE_MUTEX(lustre_mount_info_lock); struct list_head lustre_mount_info_list = LIST_HEAD_INIT(lustre_mount_info_list); -static struct lustre_mount_info *lustre_find_mount(char *name) +static struct lustre_mount_info *server_find_mount(char *name) { struct list_head *tmp; struct lustre_mount_info *lmi; @@ -60,10 +60,10 @@ static struct lustre_mount_info *lustre_find_mount(char *name) return(NULL); } -/* obd's using a mount must register for it before they call - their setup routine. They call lustre_get_mount to get the mnt struct - by name, since we can't pass the pointer to setup. */ -int lustre_register_mount(char *name, struct super_block *sb, +/* we must register an obd for a mount before we call the setup routine. + *_setup will call lustre_get_mount to get the mnt struct + by obd_name, since we can't pass the pointer to setup. */ +static int server_register_mount(char *name, struct super_block *sb, struct vfsmount *mnt) { struct lustre_mount_info *lmi; @@ -83,7 +83,7 @@ int lustre_register_mount(char *name, struct super_block *sb, down(&lustre_mount_info_lock); - if (lustre_find_mount(name)) { + if (server_find_mount(name)) { up(&lustre_mount_info_lock); OBD_FREE(lmi, sizeof(*lmi)); OBD_FREE(name_cp, strlen(name) + 1); @@ -100,12 +100,12 @@ int lustre_register_mount(char *name, struct super_block *sb, } /* when an obd no longer needs a mount */ -static int lustre_deregister_mount(char *name) +static int server_deregister_mount(char *name) { struct lustre_mount_info *lmi; down(&lustre_mount_info_lock); - lmi = lustre_find_mount(name); + lmi = server_find_mount(name); if (!lmi) { up(&lustre_mount_info_lock); CERROR("%s not registered\n", name); @@ -120,7 +120,7 @@ static int lustre_deregister_mount(char *name) /* Deregister anyone referencing the mnt. Everyone should have put_mount in *_cleanup, but this is a catch-all in case of err... */ -static void lustre_deregister_mount_all(struct vfsmount *mnt) +static void server_deregister_mount_all(struct vfsmount *mnt) { struct list_head *tmp, *n; struct lustre_mount_info *lmi; @@ -144,14 +144,14 @@ static void lustre_deregister_mount_all(struct vfsmount *mnt) /* obd's look up a registered mount using their name. This is just for initial obd setup to find the mount struct. It should not be called every time you want to mntget. */ -struct lustre_mount_info *lustre_get_mount(char *name) +struct lustre_mount_info *server_get_mount(char *name) { struct lustre_mount_info *lmi; struct lustre_sb_info *lsi; down(&lustre_mount_info_lock); - lmi = lustre_find_mount(name); + lmi = server_find_mount(name); if (!lmi) { up(&lustre_mount_info_lock); CERROR("Can't find mount for %s\n", name); @@ -181,13 +181,13 @@ static void unlock_mntput(struct vfsmount *mnt) } /* to be called from obd_cleanup methods */ -int lustre_put_mount(char *name, struct vfsmount *mnt) +int server_put_mount(char *name, struct vfsmount *mnt) { struct lustre_mount_info *lmi; struct lustre_sb_info *lsi; down(&lustre_mount_info_lock); - lmi = lustre_find_mount(name); + lmi = server_find_mount(name); if (!lmi) { up(&lustre_mount_info_lock); CERROR("Can't find mount for %s\n", name); @@ -213,7 +213,7 @@ int lustre_put_mount(char *name, struct vfsmount *mnt) up(&lustre_mount_info_lock); /* this obd should never need the mount again */ - lustre_deregister_mount(name); + server_deregister_mount(name); return 0; } @@ -221,7 +221,7 @@ int lustre_put_mount(char *name, struct vfsmount *mnt) /******* mount helper utilities *********/ -static void print_ldd(struct lustre_disk_data *ldd) +static void ldd_print(struct lustre_disk_data *ldd) { int i; @@ -240,7 +240,7 @@ static void print_ldd(struct lustre_disk_data *ldd) } } -static int parse_disk_data(struct lvfs_run_ctxt *mount_ctxt, +static int ldd_parse(struct lvfs_run_ctxt *mount_ctxt, struct lustre_disk_data *ldd) { struct lvfs_run_ctxt saved; @@ -280,7 +280,7 @@ static int parse_disk_data(struct lvfs_run_ctxt *mount_ctxt, } err = 0; - print_ldd(ldd); + ldd_print(ldd); out_close: filp_close(file, 0); @@ -289,6 +289,44 @@ out: return(err); } +static int ldd_write(struct lvfs_run_ctxt *mount_ctxt, + struct lustre_disk_data *ldd) +{ + struct lvfs_run_ctxt saved; + struct file *file; + loff_t off = 0; + unsigned long len = sizeof(struct lustre_disk_data); + int err; + + LASSERT(ldd->ldd_magic != LDD_MAGIC); + + push_ctxt(&saved, mount_ctxt, NULL); + + file = filp_open(MOUNT_DATA_FILE, O_RDWR, 0644); + if (IS_ERR(file)) { + err = PTR_ERR(file); + CERROR("cannot open %s: err = %d\n", MOUNT_DATA_FILE, err); + goto out; + } + + err = lustre_fwrite(file, ldd, len, &off); + if (err != len) { + CERROR("error writing %s: read %d of %lu\n", + MOUNT_DATA_FILE, err, len); + GOTO(out_close, err = -EINVAL); + } + + err = 0; + ldd_print(ldd); + +out_close: + filp_close(file, 0); +out: + pop_ctxt(&saved, mount_ctxt, NULL); + return(err); +} + +#if 0 int parse_last_rcvd(struct obd_device *obd, char *uuid, int *first_mount) { struct lvfs_run_ctxt saved; @@ -334,6 +372,7 @@ out: OBD_FREE(lsd, sizeof(*lsd)); return(err); } +#endif /* Get a config log from the MGS and process it. This func is called for both clients and servers. */ @@ -450,7 +489,7 @@ static int lustre_start_simple(char *obdname, char *type, char *s1, char *s2) } /* Set up a MGS to serve startup logs */ -static int lustre_start_mgs(struct super_block *sb) +static int server_start_mgs(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); struct vfsmount *mnt = lsi->lsi_srv_mnt; @@ -461,7 +500,7 @@ static int lustre_start_mgs(struct super_block *sb) /* It is impossible to have more than 1 MGS per node, since MGC wouldn't know which to connect to */ - lmi = lustre_find_mount(mgsname); + lmi = server_find_mount(mgsname); if (lmi) { lsi = s2lsi(lmi->lmi_sb); LCONSOLE_ERROR("The MGS service was already started from " @@ -471,11 +510,11 @@ static int lustre_start_mgs(struct super_block *sb) CDEBUG(D_CONFIG, "Start MGS service %s\n", mgsname); - err = lustre_register_mount(mgsname, sb, mnt); + err = server_register_mount(mgsname, sb, mnt); if (!err && ((err = lustre_start_simple(mgsname, LUSTRE_MGS_NAME, 0, 0)))) - lustre_deregister_mount(mgsname); + server_deregister_mount(mgsname); if (err) LCONSOLE_ERROR("Failed to start MGS %s (%d). Is the 'mgs' " @@ -484,7 +523,7 @@ static int lustre_start_mgs(struct super_block *sb) return err; } -static void lustre_stop_mgs(struct super_block *sb) +static void server_stop_mgs(struct super_block *sb) { struct obd_device *obd; char mgsname[] = "MGS"; @@ -601,6 +640,31 @@ static void lustre_stop_mgc(struct super_block *sb) /* class_import_put will get rid of the additional connections */ } +/* Since there's only one mgc per node, we have to change it's fs to get + access to the right disk. */ +static int server_mgc_set_fs(struct obd_device *mgc, struct super_block *sb) +{ + int err; + + /* cl_mgc_sem in mgc insures we sleep if the mgc_fs is busy */ + err = obd_set_info(mgc->obd_self_export, + strlen("set_fs"), "set_fs", + sizeof(*sb), sb); + if (err) { + CERROR("can't set_fs %d\n", err); + } + + return err; +} + +static int server_mgc_clear_fs(struct obd_device *mgc) +{ + int err; + err = obd_set_info(mgc->obd_self_export, + strlen("clear_fs"), "clear_fs", 0, NULL); + return err; +} + /* Stop MDS/OSS if nobody is using them */ static void server_stop_servers(struct super_block *sb) { @@ -641,26 +705,26 @@ static int server_initial_connect(struct super_block *sb, struct vfsmount *mnt) { struct lustre_sb_info *lsi = s2lsi(sb); struct obd_device *mgc = lsi->lsi_mgc; + struct lustre_disk_data *ldd = lsi->lsi_ldd; struct lustre_handle mgc_conn = {0, }; struct obd_export *exp = NULL; - struct mgmt_ost_info *moi = NULL; + struct mgmt_target_info *mti = NULL; int rc; LASSERT(mgc); - /* send TARGET_INITIAL_CONNECT, MGS should reply with index number. - In any case, T_I_C should send current index (usually FFFF) - and MGS can reply with actual index. */ + /* send MGMT_TARGET_ADD rpc via MGC, MGS should reply with an + index number. */ - OBD_ALLOC(moi, sizeof(*moi)); - if (!moi) { + OBD_ALLOC(mti, sizeof(*mti)); + if (!mti) { return -ENOMEM; } - strncpy(moi->moi_ostname, lsi->lsi_ldd->ldd_svname, - sizeof(moi->moi_ostname)); - strncpy(moi->moi_fullfsname, lsi->lsi_ldd->ldd_fsname, - sizeof(moi->moi_fullfsname)); - moi->moi_flags = lsi->lsi_ldd->ldd_flags; - moi->moi_stripe_index = lsi->lsi_ldd->ldd_svindex; + strncpy(mti->mti_ostname, ldd->ldd_svname, + sizeof(mti->mti_ostname)); + strncpy(mti->mti_fsname, ldd->ldd_fsname, + sizeof(mti->mti_fullfsname)); + mti->mti_flags = ldd->ldd_flags; + mti->mti_stripe_index = ldd->ldd_svindex; rc = obd_connect(&mgc_conn, mgc, &(mgc->obd_uuid), NULL); if (rc) { @@ -672,29 +736,37 @@ static int server_initial_connect(struct super_block *sb, struct vfsmount *mnt) /* FIXME use ioctl instead? eg struct obd_ioctl_data ioc_data = { 0 }; - ioc_data.ioc_inllen1 = strlen(lsi->lsi_ldd->ldd_svname) + 1; - ioc_data.ioc_inlbuf1 = lsi->lsi_ldd->ldd_svname; + ioc_data.ioc_inllen1 = strlen(ldd->ldd_svname) + 1; + ioc_data.ioc_inlbuf1 = ldd->ldd_svname; err = obd_iocontrol(OBD_IOC_START, obd->obd_self_export, sizeof ioc_data, &ioc_data, NULL); */ rc = obd_set_info(exp, strlen("add_target"), "add_target", - sizeof(*moi), moi); + sizeof(*mti), mti); obd_disconnect(exp); if (rc) { CERROR("add_target failed %d\n", rc); goto out; } - - /* FIXME rewrite last_rcvd, ldd (for new svname), drop - NEED_REGISTER|INDEX flags, change disk label */ - + /* If this flag is still set, it means we need to change our on-disk + index to what the mgs assigned us. */ + if (mti->mti_flags & LDD_F_NEED_INDEX) { + CERROR("Must change on-disk index from %#x to %#x\n", + ldd->ldd_svindex, mti->mti_stripe_index); + ldd->ldd_flags &= ~(LDD_F_NEED_INDEX | LDD_F_FIRST_START); + ldd->ldd_config_ver = 666; // FIXME + ldd->ldd_svindex = mti->mti_stripe_index; + ldd_make_sv_name(ldd); + ldd_write(&mgc->obd_lvfs_ctxt, ldd); + /* FIXME write last_rcvd?, disk label? */ + } out: - if (moi) - OBD_FREE(moi, sizeof(*moi)); + if (mti) + OBD_FREE(mti, sizeof(*mti)); return rc; } @@ -735,6 +807,9 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) } } + /* Set the mgc fs to our server disk */ + server_mgc_set_fs(lsi->lsi_mgc, sb); + /* Get a new index if needed */ if (lsi->lsi_ldd->ldd_flags & (LDD_F_NEED_INDEX | LDD_F_NEED_REGISTER)) { /* FIXME Maybe need to change NEED_INDEX to NEVER_CONNECTED, @@ -750,7 +825,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) /* Register the mount for the target */ - err = lustre_register_mount(lsi->lsi_ldd->ldd_svname, sb, mnt); + err = server_register_mount(lsi->lsi_ldd->ldd_svname, sb, mnt); if (err) goto out; @@ -761,18 +836,21 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) if (err) { CERROR("failed to start server %s: %d\n", lsi->lsi_ldd->ldd_svname, err); - lustre_deregister_mount(lsi->lsi_ldd->ldd_svname); + server_deregister_mount(lsi->lsi_ldd->ldd_svname); goto out; } if (!class_name2obd(lsi->lsi_ldd->ldd_svname)) { CERROR("no server named %s was started\n", lsi->lsi_ldd->ldd_svname); - lustre_deregister_mount(lsi->lsi_ldd->ldd_svname); + server_deregister_mount(lsi->lsi_ldd->ldd_svname); err = -ENXIO; } out: + /* Release the mgc fs for others to use */ + server_mgc_clear_fs(lsi->lsi_mgc); + if (err) server_stop_servers(sb); return(err); @@ -819,7 +897,7 @@ void lustre_free_lsi(struct super_block *sb) LASSERT(lsi->lsi_llsbi == NULL); - lustre_deregister_mount_all(lsi->lsi_srv_mnt); + server_deregister_mount_all(lsi->lsi_srv_mnt); OBD_FREE(lsi, sizeof(*lsi)); s2lsi_nocast(sb) = NULL; @@ -832,7 +910,7 @@ void lustre_free_lsi(struct super_block *sb) /*************** server mount ******************/ /* Kernel mount using mount options in MOUNT_DATA_FILE */ -static struct vfsmount *lustre_kern_mount(struct super_block *sb) +static struct vfsmount *server_kernel_mount(struct super_block *sb) { struct lvfs_run_ctxt mount_ctxt; struct lustre_sb_info *lsi = s2lsi(sb); @@ -865,7 +943,7 @@ static struct vfsmount *lustre_kern_mount(struct super_block *sb) mount_ctxt.pwd = mnt->mnt_root; mount_ctxt.fs = get_ds(); - err = parse_disk_data(&mount_ctxt, ldd); + err = ldd_parse(&mount_ctxt, ldd); unlock_mntput(mnt); if (err) { @@ -943,7 +1021,7 @@ static void server_put_super(struct super_block *sb) /* If they wanted the mgs to stop separately from the mdt, they should have put it on a different device. */ if (lsi->lsi_ldd->ldd_flags & LDD_F_SV_TYPE_MGMT) - lustre_stop_mgs(sb); + server_stop_mgs(sb); /* clean the mgc and sb */ lustre_common_put_super(sb); @@ -1016,7 +1094,7 @@ static int server_fill_super(struct super_block *sb) ENTRY; /* the One True Mount */ - mnt = lustre_kern_mount(sb); + mnt = server_kernel_mount(sb); if (IS_ERR(mnt)) { err = PTR_ERR(mnt); CERROR("Unable to mount device %s: %d\n", @@ -1039,7 +1117,7 @@ static int server_fill_super(struct super_block *sb) /* start MGS before MGC */ if (lsi->lsi_ldd->ldd_flags & LDD_F_SV_TYPE_MGMT) { - err = lustre_start_mgs(sb); + err = server_start_mgs(sb); if (err) { CERROR("ignoring Failed MGS start!!\n"); //GOTO(out_mnt, err); @@ -1074,7 +1152,7 @@ static int server_fill_super(struct super_block *sb) out_mnt: if (mgs_service) - lustre_stop_mgs(sb); + server_stop_mgs(sb); /* mgc is stopped in lustre_fill_super */ unlock_mntput(mnt); out: @@ -1094,7 +1172,7 @@ void lustre_common_put_super(struct super_block *sb) lustre_free_lsi(sb); } -static void print_lmd(struct lustre_mount_data *lmd) +static void lmd_print(struct lustre_mount_data *lmd) { int i; @@ -1114,7 +1192,7 @@ static void print_lmd(struct lustre_mount_data *lmd) CDEBUG(D_MOUNT, "options: %s\n", lmd->lmd_opts); } -static int parse_lmd(char *options, struct lustre_mount_data *lmd) +static int lmd_parse(char *options, struct lustre_mount_data *lmd) { char *s1, *s2, *devname = NULL; struct lustre_mount_data *raw = (struct lustre_mount_data *)options; @@ -1222,7 +1300,7 @@ static int parse_lmd(char *options, struct lustre_mount_data *lmd) lmd->lmd_magic = LMD_MAGIC; - print_lmd(lmd); + lmd_print(lmd); RETURN(0); invalid: @@ -1247,7 +1325,7 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent) lmd = lsi->lsi_lmd; /* Figure out the lmd from the mount options */ - if (parse_lmd((char *)data, lmd)) { + if (lmd_parse((char *)data, lmd)) { lustre_free_lsi(sb); RETURN(-EINVAL); } @@ -1349,7 +1427,7 @@ int lustre_unregister_fs(void) EXPORT_SYMBOL(lustre_register_client_fill_super); EXPORT_SYMBOL(lustre_common_put_super); EXPORT_SYMBOL(lustre_get_process_log); -EXPORT_SYMBOL(lustre_get_mount); -EXPORT_SYMBOL(lustre_put_mount); +EXPORT_SYMBOL(server_get_mount); +EXPORT_SYMBOL(server_put_mount); diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 66efd3c..d9fe902 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -1352,7 +1352,7 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf, LUSTRE_CFG_BUFLEN(lcfg, 2) < 1) RETURN(-EINVAL); - lmi = lustre_get_mount(obd->obd_name); + lmi = server_get_mount(obd->obd_name); if (lmi) { /* We already mounted in lustre_fill_super. lcfg bufs 1, 2, 4 (device, fstype, mount opts) are ignored.*/ @@ -1486,7 +1486,7 @@ err_ops: filter_iobuf_pool_done(filter); err_mntput: if (lmi) { - lustre_put_mount(obd->obd_name, mnt); + server_put_mount(obd->obd_name, mnt); } else { /* old method */ unlock_kernel(); @@ -1647,7 +1647,7 @@ static int filter_cleanup(struct obd_device *obd) obd->obd_name, filter->fo_vfsmnt, atomic_read(&filter->fo_vfsmnt->mnt_count)); - must_put = lustre_put_mount(obd->obd_name, filter->fo_vfsmnt); + must_put = server_put_mount(obd->obd_name, filter->fo_vfsmnt); /* must_put is for old method (l_p_m returns non-0 on err) */ /* We can only unlock kernel if we are in the context of sys_ioctl, diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index fd27ed45..bd2da48 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -566,20 +566,15 @@ void lustre_swab_mds_body (struct mds_body *b) CLASSERT(offsetof(typeof(*b), padding_4) != 0); } -void lustre_swab_mgmt_ost_info(struct mgmt_ost_info *oinfo) +void lustre_swab_mgmt_target_info(struct mgmt_target_info *mti) { - __swab64s(&oinfo->moi_nid); - __swab32s(&oinfo->moi_stripe_index); - __swab32s(&oinfo->moi_flags); -} - -void lustre_swab_mgmt_mds_info(struct mgmt_mds_info *minfo) -{ - __swab64s(&minfo->mmi_nid); - __swab32s(&minfo->mmi_index); - __swab32s(&minfo->mmi_pattern); - __swab64s(&minfo->mmi_stripe_size); - __swab64s(&minfo->mmi_stripe_offset); + __swab64s(&mti->mti_nid); + __swab32s(&mti->mti_config_ver); + __swab32s(&mti->mti_flags); + __swab32s(&mti->mti_stripe_index); + __swab32s(&mti->mti_stripe_pattern); + __swab64s(&mti->mti_stripe_size); + __swab64s(&mti->mti_stripe_offset); } static void lustre_swab_obd_dqinfo (struct obd_dqinfo *i) diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 2a01bf6..b815553 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -550,7 +550,8 @@ int write_local_files(struct mkfs_opts *mop) } memset(&lsd, 0, sizeof(lsd)); strncpy(lsd.lsd_uuid, mop->mo_ldd.ldd_svname, sizeof(lsd.lsd_uuid)); - lsd.lsd_index = mop->mo_index; + // FIXME any need for the lsd_index? + lsd.lsd_index = mop->mo_ldd.ldd_svindex; lsd.lsd_feature_compat |= cpu_to_le32(LR_COMPAT_COMMON_LR); lsd.lsd_server_size = cpu_to_le32(LR_SERVER_SIZE); lsd.lsd_client_start = cpu_to_le32(LR_CLIENT_START); @@ -829,26 +830,6 @@ out_jt: } #endif -/* Make the mdt/ost server obd name based on the filesystem name */ -static void make_sv_name(struct mkfs_opts *mop) -{ - /* FIXME if we're not given an index, we have to change our name - later -- can't have two servers with the same name. - So rewrite ost log, last_rcvd, and disk label, or we need to talk - to MGMT now to get index # */ - - if (IS_MDT(&mop->mo_ldd) || IS_OST(&mop->mo_ldd)) { - sprintf(mop->mo_ldd.ldd_svname, "%.8s-%s%04x", - mop->mo_ldd.ldd_fsname, - IS_MDT(&mop->mo_ldd) ? "MDT" : "OST", - mop->mo_index); - } else { - sprintf(mop->mo_ldd.ldd_svname, "MGMT"); - } - mop->mo_ldd.ldd_svindex = mop->mo_index; - vprint("Server name: %s\n", mop->mo_ldd.ldd_svname); -} - void set_defaults(struct mkfs_opts *mop) { mop->mo_ldd.ldd_magic = LDD_MAGIC; @@ -861,8 +842,8 @@ void set_defaults(struct mkfs_opts *mop) else mop->mo_ldd.ldd_mount_type = LDD_MT_LDISKFS; + mop->mo_ldd.ldd_svindex = -1; mop->mo_stripe_count = 1; - mop->mo_index = -1; } static inline void badopt(char opt, char *type) @@ -958,7 +939,7 @@ int main(int argc , char *const argv[]) exit(0); case 'i': if (IS_MDT(&mop.mo_ldd) || IS_OST(&mop.mo_ldd)) { - mop.mo_index = atol(optarg); + mop.mo_ldd.ldd_svindex = atol(optarg); mop.mo_ldd.ldd_flags &= ~LDD_F_NEED_INDEX; } else { badopt(opt, "MDT,OST"); @@ -1128,7 +1109,7 @@ int main(int argc , char *const argv[]) (mop.mo_ldd.ldd_mount_type == LDD_MT_SMFS)) mop.mo_flags |= MO_IS_LOOP; - make_sv_name(&mop); + ldd_make_sv_name(&(mop.mo_ldd)); /* Create the loopback file */ if (mop.mo_flags & MO_IS_LOOP) { -- 1.8.3.1