From 5688bfc60fe4ea72ad927af81182c86ae3a132d7 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 30 Nov 2005 01:08:28 +0000 Subject: [PATCH] Branch b1_4_mountconf b=8007 course correction for mgmt rpc's. Lin, this is the direction we need to go. I will continue to work on this. --- lustre/include/linux/lustre_disk.h | 10 +-- lustre/include/linux/lustre_export.h | 12 ---- lustre/include/linux/lustre_idl.h | 8 +-- lustre/include/linux/lustre_mgs.h | 34 --------- lustre/mgc/mgc_request.c | 109 ++++++----------------------- lustre/mgs/mgs_handler.c | 132 ++++++++++++----------------------- lustre/mgs/mgs_llog.c | 25 ------- lustre/obdclass/obd_mount.c | 104 +++++++++++++++++++++------ lustre/ptlrpc/pack_generic.c | 11 ++- lustre/utils/mkfs_lustre.c | 3 +- lustre/utils/wirecheck.c | 5 +- lustre/utils/wiretest.c | 10 ++- 12 files changed, 168 insertions(+), 295 deletions(-) diff --git a/lustre/include/linux/lustre_disk.h b/lustre/include/linux/lustre_disk.h index 76232cb..3453c4b 100644 --- a/lustre/include/linux/lustre_disk.h +++ b/lustre/include/linux/lustre_disk.h @@ -42,10 +42,11 @@ #define LDD_MAGIC 0xbabb0001 -#define LDD_F_SV_TYPE_MDT 0x0001 -#define LDD_F_SV_TYPE_OST 0x0002 -#define LDD_F_SV_TYPE_MGMT 0x0004 -#define LDD_F_NEED_INDEX 0x0010 +#define LDD_F_SV_TYPE_MDT 0x0001 +#define LDD_F_SV_TYPE_OST 0x0002 +#define LDD_F_SV_TYPE_MGMT 0x0004 +#define LDD_F_NEED_INDEX 0x0010 +#define LDD_F_FIRST_START 0x0020 enum ldd_mount_type { LDD_MT_EXT3 = 0, @@ -74,6 +75,7 @@ struct lustre_disk_data { __u32 ldd_config_ver; /* we have integrated all llog steps through this llog ver. */ __u32 ldd_flags; /* LDD_SV_TYPE */ + __u32 ldd_svindex; /* server index (0001), must match svname */ char ldd_fsname[64]; /* filesystem this server is part of */ char ldd_svname[64]; /* this server's name (lustre-mdt0001) */ __u16 ldd_mgsnid_count; /* how many failover nids we have for the MGS */ diff --git a/lustre/include/linux/lustre_export.h b/lustre/include/linux/lustre_export.h index ebdebab..dd25d4c 100644 --- a/lustre/include/linux/lustre_export.h +++ b/lustre/include/linux/lustre_export.h @@ -8,19 +8,7 @@ #include #include -/*export struct for mount-conf */ -/*FIXME: some attributes Mixed now*/ /* Data stored per client in the last_rcvd file. In le32 order. */ -struct mgs_client_data; - -struct mgs_export_data { - struct list_head med_open_head; - spinlock_t med_open_lock; /* lock med_open_head, mfd_list*/ - struct mgs_client_data *med_mcd; - loff_t med_lr_off; - int med_lr_idx; -}; - struct mds_client_data; struct mds_export_data { diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index 9b4515c..f09e8ee 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -934,15 +934,14 @@ typedef enum { MGMT_CONNECT = 250, MGMT_DISCONNECT, MGMT_EXCEPTION, /* node died, etc. */ - MGMT_FIRST_CONNECT, /* first connect. */ - MGMT_OST_ADD, - MGMT_OST_DEL, - MGMT_MDS_ADD, + MGMT_TARGET_ADD, + MGMT_TARGET_DEL, MGMT_LAST_OPC } mgs_cmd_t; #define NAME_MAXLEN 64 #define UUID_MAXLEN NAME_MAXLEN + 5 + struct mgmt_ost_info { struct list_head moi_list; char moi_fullfsname[NAME_MAXLEN]; @@ -951,6 +950,7 @@ struct mgmt_ost_info { 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); diff --git a/lustre/include/linux/lustre_mgs.h b/lustre/include/linux/lustre_mgs.h index 4c55963..80b935f 100644 --- a/lustre/include/linux/lustre_mgs.h +++ b/lustre/include/linux/lustre_mgs.h @@ -22,43 +22,9 @@ #include #include -#define MGS_LR_SERVER_SIZE 512 - -#define MGS_LR_CLIENT_START 8192 -#define MGS_LR_CLIENT_SIZE 128 - #define MGS_ROCOMPAT_SUPP 0x00000001 #define MGS_INCOMPAT_SUPP (0) -/* Data stored per client in the last_rcvd file. In le32 order. */ -struct mgs_client_data { - __u8 mcd_uuid[40]; /* client UUID */ - __u64 mcd_last_transno; /* last completed transaction ID */ - __u64 mcd_last_xid; /* xid for the last transaction */ - __u32 mcd_last_result; /* result from last RPC */ - __u32 mcd_last_data; /* per-op data (disposition for open &c.) */ - __u8 mcd_padding[MGS_LR_CLIENT_SIZE - 64]; -}; - -/* Data stored per server at the head of the last_rcvd file. In le32 order.*/ -struct mgs_server_data { - __u8 msd_uuid[40]; /* server UUID */ - __u64 msd_last_transno; /* last completed transaction ID */ - __u64 msd_mount_count; /* MDS incarnation number */ - __u64 msd_unused; - __u32 msd_feature_compat; /* compatible feature flags */ - __u32 msd_feature_rocompat;/* read-only compatible feature flags */ - __u32 msd_feature_incompat;/* incompatible feature flags */ - __u32 msd_server_size; /* size of server data area */ - __u32 msd_client_start; /* start of per-client data area */ - __u16 msd_client_size; /* size of per-client data area */ - __u16 msd_subdir_count; /* number of subdirectories for objects */ - __u64 msd_catalog_oid; /* recovery catalog object id */ - __u32 msd_catalog_ogen; /* recovery catalog inode generation */ - __u8 msd_peeruuid[40]; /* UUID of LOV/OSC associated with MDS */ - __u8 msd_padding[MGS_LR_SERVER_SIZE - 140]; -}; - typedef enum { MCID = 1, OTID = 2, diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 948a0cd..9593239 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -48,89 +48,9 @@ #include "mgc_internal.h" -int mgc_first_connect(struct obd_export *exp, int disk_type, - char *full_fsname, char *node_name, - int *index) -{ - struct ptlrpc_request *req; - int size[3] = {sizeof(disk_type), NAME_MAXLEN, NAME_MAXLEN}; - int *type; - char *fsname, *nodename; - int rc; - ENTRY; - - req = ptlrpc_prep_req(class_exp2cliimp(exp), MGMT_FIRST_CONNECT, - 3, size, NULL); - if (!req) - RETURN(rc = -ENOMEM); - - type = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*type)); - *type = disk_type; - - fsname = lustre_msg_buf(req->rq_reqmsg, 1, NAME_MAXLEN); - memcpy(fsname, full_fsname, strlen(full_fsname)); - - nodename = lustre_msg_buf(req->rq_reqmsg, 2, NAME_MAXLEN); - memcpy(nodename, node_name, strlen(node_name)); - - rc = ptlrpc_queue_wait(req); - if (!rc) { - int *rep_index; - rep_index = lustre_swab_repbuf(req, 0, sizeof(int), - __swab32s); - if (*rep_index >= 0){ - CDEBUG(D_INODE, "Get index: %d from mgs.", *rep_index); - *index = *rep_index; - } - else - CERROR("Can not get index from mgs. rc:%d", *rep_index); - } - - ptlrpc_req_finished(req); - - RETURN(rc); -} -EXPORT_SYMBOL(mgc_first_connect); -int mgc_mds_add(struct obd_export *exp, struct mgmt_mds_info *mmi) -{ - struct ptlrpc_request *req; - struct mgmt_mds_info *req_mmi, *rep_mmi; - int size = sizeof(*req_mmi); - int rep_size = sizeof(rep_mmi); - int rc; - ENTRY; - - req = ptlrpc_prep_req(class_exp2cliimp(exp), MGMT_MDS_ADD, - 1, &size, NULL); - if (!req) - RETURN(rc = -ENOMEM); - - req_mmi = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*req_mmi)); - memcpy(req_mmi, mmi, sizeof(*req_mmi)); - - req->rq_replen = lustre_msg_size(1, &rep_size); - - rc = ptlrpc_queue_wait(req); - if (!rc) { - int index; - rep_mmi = lustre_swab_repbuf(req, 0, sizeof(*rep_mmi), - lustre_swab_mgmt_mds_info); - index = rep_mmi->mmi_index; - if (index != mmi->mmi_index) { - CERROR("MDS ADD failed. rc = %d\n", index); - GOTO(out, rc = index); - } else - CERROR("MDS ADD OK. (index = %d)\n", index); - } -out: - ptlrpc_req_finished(req); - - RETURN(rc); -} -EXPORT_SYMBOL(mgc_mds_add); - -int mgc_ost_add(struct obd_export *exp, struct mgmt_ost_info *moi) +/* Get index and add to config llog, depending on flags */ +int mgc_target_add(struct obd_export *exp, struct mgmt_ost_info *moi) { struct ptlrpc_request *req; struct mgmt_ost_info *req_moi, *rep_moi; @@ -139,7 +59,7 @@ int mgc_ost_add(struct obd_export *exp, struct mgmt_ost_info *moi) int rc; ENTRY; - req = ptlrpc_prep_req(class_exp2cliimp(exp), MGMT_OST_ADD, + req = ptlrpc_prep_req(class_exp2cliimp(exp), MGMT_TARGET_ADD, 1, &size, NULL); if (!req) RETURN(rc = -ENOMEM); @@ -168,7 +88,8 @@ out: } EXPORT_SYMBOL(mgc_ost_add); -int mgc_ost_del(struct obd_export *exp, struct mgmt_ost_info *moi) +/* Remove from config llog */ +int mgc_target_del(struct obd_export *exp, struct mgmt_ost_info *moi) { struct ptlrpc_request *req; struct mgmt_ost_info *req_moi, *rep_moi; @@ -176,7 +97,7 @@ int mgc_ost_del(struct obd_export *exp, struct mgmt_ost_info *moi) int rc; ENTRY; - req = ptlrpc_prep_req(class_exp2cliimp(exp), MGMT_OST_DEL, + req = ptlrpc_prep_req(class_exp2cliimp(exp), MGMT_TARGET_DEL, 1, &size, NULL); if (!req) RETURN(rc = -ENOMEM); @@ -436,10 +357,11 @@ int mgc_set_info(struct obd_export *exp, obd_count keylen, { struct obd_import *imp = class_exp2cliimp(exp); int rc = -EINVAL; + ENTRY; /* Try to "recover" the initial connection; i.e. retry */ if (keylen == strlen("initial_recov") && - memcmp(key, "initial_recov", strlen("initial_recov")) == 0) { + memcmp(key, "initial_recov", keylen) == 0) { if (vallen != sizeof(int)) RETURN(-EINVAL); imp->imp_initial_recov = *(int *)val; @@ -449,7 +371,7 @@ int mgc_set_info(struct obd_export *exp, obd_count keylen, } /* Turn off initial_recov after we try all backup servers once */ if (keylen == strlen(INIT_RECOV_BACKUP) && - memcmp(key, INIT_RECOV_BACKUP, strlen(INIT_RECOV_BACKUP)) == 0) { + memcmp(key, INIT_RECOV_BACKUP, keylen) == 0) { if (vallen != sizeof(int)) RETURN(-EINVAL); imp->imp_initial_recov_bk = *(int *)val; @@ -457,7 +379,18 @@ int mgc_set_info(struct obd_export *exp, obd_count keylen, exp->exp_obd->obd_name, imp->imp_initial_recov_bk); RETURN(0); } - return(rc); + /* Hack alert */ + if (keylen == strlen("register") && + memcmp(key, "register", keylen) == 0) { + struct mgmt_ost_info *moi; + if (vallen != sizeof(mgmt_ost_info)) + RETURN(-EINVAL); + moi = (struct mgmt_ost_info *)val; + CERROR("register %s %#x\n", moi->moi_ostname, moi->moi_flags); + rc = mgc_target_add(exp, moi); + RETURN(rc); + } + RETURN(rc); } static int mgc_import_event(struct obd_device *obd, diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 4f465b4..f83d5b2 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -54,41 +54,23 @@ static int mgs_connect(struct lustre_handle *conn, struct obd_device *obd, struct obd_uuid *cluuid, struct obd_connect_data *data) { struct obd_export *exp; - struct mgs_export_data *med; - struct mgs_client_data *mcd; int rc, abort_recovery; ENTRY; if (!conn || !obd || !cluuid) RETURN(-EINVAL); - /* Check for aborted recovery. */ - spin_lock_bh(&obd->obd_processing_task_lock); - abort_recovery = obd->obd_abort_recovery; - spin_unlock_bh(&obd->obd_processing_task_lock); - if (abort_recovery) - target_abort_recovery(obd); - rc = class_connect(conn, obd, cluuid); if (rc) RETURN(rc); exp = class_conn2export(conn); LASSERT(exp); - med = &exp->exp_mgs_data; if (data != NULL) { data->ocd_connect_flags &= MGMT_CONNECT_SUPPORTED; exp->exp_connect_flags = data->ocd_connect_flags; } - OBD_ALLOC(mcd, sizeof(*mcd)); - if (!mcd) { - CERROR("mgs: out of memory for client data\n"); - GOTO(out, rc = -ENOMEM); - } - - memcpy(mcd->mcd_uuid, cluuid, sizeof(mcd->mcd_uuid)); - med->med_mcd = mcd; #if 0 /* FIXME: recovery of connection*/ rc = mgs_client_add(obd, &obd->u.mgs, med, -1); @@ -96,10 +78,6 @@ static int mgs_connect(struct lustre_handle *conn, struct obd_device *obd, #endif out: if (rc) { - if (mcd) { - OBD_FREE(mcd, sizeof(*mcd)); - med->med_mcd = NULL; - } class_disconnect(exp); } else { class_export_put(exp); @@ -108,15 +86,6 @@ out: RETURN(rc); } -static int mgs_init_export(struct obd_export *exp) -{ - struct mgs_export_data *med = &exp->exp_mgs_data; - - INIT_LIST_HEAD(&med->med_open_head); - spin_lock_init(&med->med_open_lock); - RETURN(0); -} - static int mgs_disconnect(struct obd_export *exp) { unsigned long irqflags; @@ -280,12 +249,46 @@ static int mgs_cleanup(struct obd_device *obd) RETURN(0); } +static int mgmt_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); + int index, rc; + + OBD_ALLOC(moi, sizeof(*moi)); + if (!moi) + GOTO(out, rc = -ENOMEM); + req_moi = lustre_swab_reqbuf(req, 0, sizeof(*moi), + lustre_swab_mgmt_ost_info); + memcpy(moi, req_moi, sizeof(*moi)); + + /* NEED_INDEX implies FIRST_START, but not vice-versa */ + if (moi->moi_flags & LDD_F_NEED_INDEX) { + rc = mgs_get_index(moi); + // rc = mgmt_handle_first_connect(req); + } + + if (moi->moi_flags & LDD_F_SV_TYPE_MDT) { + rc = llog_add_mds(obd, moi); + } + +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)); + if (rc) + rep_moi->moi_stripe_index = rc; + return rc; +} + int mgs_handle(struct ptlrpc_request *req) { - int fail = OBD_FAIL_MGMT_ALL_REPLY_NET; - int rc = 0; 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; OBD_FAIL_RETURN(OBD_FAIL_MGMT_ALL_REQUEST_NET | OBD_FAIL_ONCE, 0); @@ -293,42 +296,14 @@ int mgs_handle(struct ptlrpc_request *req) LASSERT(current->journal_info == NULL); /* XXX identical to MDS */ if (req->rq_reqmsg->opc != MGMT_CONNECT) { - struct mgs_export_data *med; - int abort_recovery; - if (req->rq_export == NULL) { CERROR("lustre_mgs: operation %d on unconnected MGS\n", req->rq_reqmsg->opc); req->rq_status = -ENOTCONN; GOTO(out, rc = -ENOTCONN); } - - med = &req->rq_export->exp_mgs_data; obd = req->rq_export->exp_obd; mgs = &obd->u.mgs; - - /* sanity check: if the xid matches, the request must - * be marked as a resent or replayed */ - if (req->rq_xid == med->med_mcd->mcd_last_xid) - LASSERTF(lustre_msg_get_flags(req->rq_reqmsg) & - (MSG_RESENT | MSG_REPLAY), - "rq_xid "LPU64" matches last_xid, " - "expected RESENT flag\n", - req->rq_xid); - /* else: note the opposite is not always true; a - * RESENT req after a failover will usually not match - * the last_xid, since it was likely never - * committed. A REPLAYed request will almost never - * match the last xid, however it could for a - * committed, but still retained, open. */ - - /* Check for aborted recovery. */ - spin_lock_bh(&obd->obd_processing_task_lock); - abort_recovery = obd->obd_abort_recovery; - spin_unlock_bh(&obd->obd_processing_task_lock); - if (abort_recovery) { - target_abort_recovery(obd); - } } switch (req->rq_reqmsg->opc) { @@ -380,13 +355,13 @@ int mgs_handle(struct ptlrpc_request *req) OBD_FAIL_RETURN(OBD_FAIL_MGMT_FIRST_CONNECT, 0); rc = mgmt_handle_first_connect(req); break; - case MGMT_OST_ADD: - CDEBUG(D_INODE, "ost add\n"); - rc = mgmt_handle_ost_add(req); + case MGMT_TARGET_ADD: + CDEBUG(D_INODE, "target add\n"); + rc = mgmt_handle_target_add(req); break; - case MGMT_OST_DEL: - CDEBUG(D_INODE, "ost del\n"); - rc = mgmt_handle_ost_del(req); + 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"); @@ -425,29 +400,9 @@ int mgs_handle(struct ptlrpc_request *req) LASSERT(current->journal_info == NULL); - /* If we're DISCONNECTing, the mgs_export_data is already freed */ - if (!rc && req->rq_reqmsg->opc != MGMT_DISCONNECT) { - struct mgs_export_data *med = &req->rq_export->exp_mgs_data; - req->rq_repmsg->last_xid = - le64_to_cpu(med->med_mcd->mcd_last_xid); - - target_committed_to_req(req); - } - - EXIT; out: - - if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_LAST_REPLAY) { - if (obd && obd->obd_recovering) { - DEBUG_REQ(D_HA, req, "LAST_REPLAY, queuing reply"); - return target_queue_final_reply(req, rc); - } - /* Lost a race with recovery; let the error path DTRT. */ - rc = req->rq_status = -ENOTCONN; - } - target_send_reply(req, rc, fail); - return 0; + RETURN(0); } static int mgt_setup(struct obd_device *obd, obd_count len, void *buf) @@ -507,7 +462,6 @@ struct lvfs_callback_ops mgs_lvfs_ops = { static struct obd_ops mgs_obd_ops = { .o_owner = THIS_MODULE, .o_connect = mgs_connect, - .o_init_export = mgs_init_export, .o_disconnect = mgs_disconnect, .o_setup = mgs_setup, .o_precleanup = mgs_precleanup, diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index a6439dd..657b85b 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -972,31 +972,6 @@ out: } EXPORT_SYMBOL(mgmt_handle_mds_add); -int mgmt_handle_ost_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); - int index, rc; - - OBD_ALLOC(moi, sizeof(*moi)); - if (!moi) - GOTO(out, rc = -ENOMEM); - req_moi = lustre_swab_reqbuf(req, 0, sizeof(*moi), - lustre_swab_mgmt_ost_info); - memcpy(moi, req_moi, sizeof(*moi)); - - rc = llog_add_ost(obd, moi); -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)); - if (rc) - rep_moi->moi_stripe_index = rc; - return rc; -} -EXPORT_SYMBOL(mgmt_handle_ost_add); int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg) diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 50a3ce2..88d91dc 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -637,6 +637,67 @@ static void server_stop_servers(struct super_block *sb) } } +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_handle mgc_conn = {0, }; + struct obd_export *exp = NULL; + struct mgmt_ost_info *moi = 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. */ + + OBD_ALLOC(moi, sizeof(*moi)); + if (!moi) { + 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; + + rc = obd_connect(&mgc_conn, mgc, &(mgc->obd_uuid), NULL); + if (rc) { + CERROR("connect failed %d\n", rc); + goto out; + } + exp = class_conn2export(&mgc_conn); + LASSERT(exp->exp_obd == mgc); + + /* 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; + + 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); + 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 */ + + +out: + if (moi) + OBD_FREE(moi, sizeof(*moi)); + return rc; +} + /* Start targets */ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) { @@ -654,8 +715,10 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) if (!obd) { //FIXME pre-rename, should eventually be LUSTRE_MDS_NAME err = lustre_start_simple("MDS", LUSTRE_MDT_NAME, 0, 0); - if (err) + if (err) { CERROR("failed to start MDS: %d\n", err); + goto out; + } } } @@ -663,42 +726,37 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) if (lsi->lsi_ldd->ldd_flags & LDD_F_SV_TYPE_OST) { /* make sure OSS is started */ obd = class_name2obd("OSS"); - if (!obd) + if (!obd) { err = lustre_start_simple("OSS", LUSTRE_OSS_NAME, 0, 0); + if (err) { + CERROR("failed to start OSS: %d\n", err); + goto out; + } + } } /* Get a new index if needed */ - if (lsi->lsi_ldd->ldd_flags & LDD_F_NEED_INDEX) { - // FIXME implement + if (lsi->lsi_ldd->ldd_flags & (LDD_F_NEED_INDEX | LDD_F_NEED_REGISTER)) { + /* FIXME Maybe need to change NEED_INDEX to NEVER_CONNECTED, + in case index number was given but llog still is needed.*/ CERROR("Need new target index from MGS!\n"); - /* send TARGET_INITIAL_CONNECT, MGS should reply with index - number. Maybe need to change NEED_INDEX to NEVER_CONNECTED, - in case index number was given but llog still is needed. - In any case, T_I_C should send current index (usually FFFF) - and MGS can reply with actual index. */ - /* FIXME rewrite last_rcvd, ldd (for new svname), drop - NEVER_CONNECTED flag, change disk label? */ + err = server_initial_connect(sb, mnt); + if (err) { + CERROR("Initial connect failed for %s: %d\n", + lsi->lsi_ldd->ldd_svname, err); + goto out; + } } - /* The MGC starts targets using the svname llog */ - obd = lsi->lsi_mgc; - LASSERT(obd); /* Register the mount for the target */ err = lustre_register_mount(lsi->lsi_ldd->ldd_svname, sb, mnt); if (err) goto out; - /* FIXME replace ioctl with lustre_get_process_log - 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; - - err = obd_iocontrol(OBD_IOC_START, obd->obd_self_export, - sizeof ioc_data, &ioc_data, NULL); - */ + /* The MGC starts targets using the svname llog */ cfg.cfg_instance = NULL; - cfg.cfg_uuid = obd->obd_uuid; + cfg.cfg_uuid = lsi->lsi_mgc->obd_uuid; lustre_get_process_log(sb, lsi->lsi_ldd->ldd_svname, &cfg); if (err) { CERROR("failed to start server %s: %d\n", diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 0f67951..fd27ed45 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -570,6 +570,7 @@ void lustre_swab_mgmt_ost_info(struct mgmt_ost_info *oinfo) { __swab64s(&oinfo->moi_nid); __swab32s(&oinfo->moi_stripe_index); + __swab32s(&oinfo->moi_flags); } void lustre_swab_mgmt_mds_info(struct mgmt_mds_info *minfo) @@ -1026,12 +1027,10 @@ void lustre_assert_wire_constants(void) (long long)MGMT_DISCONNECT); LASSERTF(MGMT_EXCEPTION == 252, " found %lld\n", (long long)MGMT_EXCEPTION); - LASSERTF(MGMT_FIRST_CONNECT == 253, " found %lld\n", - (long long)MGMT_FIRST_CONNECT); - LASSERTF(MGMT_OST_ADD == 254, " found %lld\n", - (long long)MGMT_OST_ADD); - LASSERTF(MGMT_OST_DEL == 255, " found %lld\n", - (long long)MGMT_OST_DEL); + LASSERTF(MGMT_TARGET_ADD == 253, " found %lld\n", + (long long)MGMT_TARGET_ADD); + LASSERTF(MGMT_TARGET_DEL == 254, " found %lld\n", + (long long)MGMT_TARGET_DEL); LASSERTF(OBD_PING == 400, " found %lld\n", (long long)OBD_PING); LASSERTF(OBD_LOG_CANCEL == 401, " found %lld\n", diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 2685cae..2a01bf6 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -845,6 +845,7 @@ static void make_sv_name(struct mkfs_opts *mop) } 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); } @@ -852,7 +853,7 @@ void set_defaults(struct mkfs_opts *mop) { mop->mo_ldd.ldd_magic = LDD_MAGIC; mop->mo_ldd.ldd_config_ver = 0; - mop->mo_ldd.ldd_flags = LDD_F_NEED_INDEX; + mop->mo_ldd.ldd_flags = LDD_F_NEED_INDEX | LDD_F_NEED_REGISTER; mop->mo_ldd.ldd_mgsnid_count = 0; strcpy(mop->mo_ldd.ldd_fsname, "lustre"); if (get_os_version() == 24) diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index ee4a850..07614e3 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -928,9 +928,8 @@ main(int argc, char **argv) CHECK_VALUE(MGMT_CONNECT); CHECK_VALUE(MGMT_DISCONNECT); CHECK_VALUE(MGMT_EXCEPTION); - CHECK_VALUE(MGMT_FIRST_CONNECT); - CHECK_VALUE(MGMT_OST_ADD); - CHECK_VALUE(MGMT_OST_DEL); + CHECK_VALUE(MGMT_TARGET_ADD); + CHECK_VALUE(MGMT_TARGET_DEL); CHECK_VALUE(OBD_PING); CHECK_VALUE(OBD_LOG_CANCEL); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index c4814ff..8ff2b29 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -196,12 +196,10 @@ void lustre_assert_wire_constants(void) (long long)MGMT_DISCONNECT); LASSERTF(MGMT_EXCEPTION == 252, " found %lld\n", (long long)MGMT_EXCEPTION); - LASSERTF(MGMT_FIRST_CONNECT == 253, " found %lld\n", - (long long)MGMT_FIRST_CONNECT); - LASSERTF(MGMT_OST_ADD == 254, " found %lld\n", - (long long)MGMT_OST_ADD); - LASSERTF(MGMT_OST_DEL == 255, " found %lld\n", - (long long)MGMT_OST_DEL); + LASSERTF(MGMT_TARGET_ADD == 253, " found %lld\n", + (long long)MGMT_TARGET_ADD); + LASSERTF(MGMT_TARGET_DEL == 254, " found %lld\n", + (long long)MGMT_TARGET_DEL); LASSERTF(OBD_PING == 400, " found %lld\n", (long long)OBD_PING); LASSERTF(OBD_LOG_CANCEL == 401, " found %lld\n", -- 1.8.3.1