uint32_t lcfg_num;
uint32_t lcfg_flags;
uint64_t lcfg_nid;
- uint32_t lcfg_nal;
uint32_t lcfg_bufcount;
uint32_t lcfg_buflens[0];
struct lustre_mount_data {
uint32_t lmd_magic;
uint32_t lmd_version;
- uint64_t lmd_local_nid;
- uint64_t lmd_server_nid;
- uint32_t lmd_nal;
- uint32_t lmd_server_ipaddr;
- uint32_t lmd_port;
+ uint64_t lmd_nid;
char lmd_mds[64];
char lmd_profile[64];
};
MDS_UNLINK_REC = LLOG_OP_MAGIC | 0x10000 | (MDS_REINT << 8) | REINT_UNLINK,
MDS_SETATTR_REC = LLOG_OP_MAGIC | 0x10000 | (MDS_REINT << 8) | REINT_SETATTR,
OBD_CFG_REC = LLOG_OP_MAGIC | 0x20000,
- PTL_CFG_REC = LLOG_OP_MAGIC | 0x30000,
+// unused = LLOG_OP_MAGIC | 0x30000,
LLOG_GEN_REC = LLOG_OP_MAGIC | 0x40000,
LLOG_HDR_MAGIC = LLOG_OP_MAGIC | 0x45539,
LLOG_LOGID_MAGIC = LLOG_OP_MAGIC | 0x4553b,
extern void lustre_swab_llog_rec(struct llog_rec_hdr *rec,
struct llog_rec_tail *tail);
-struct portals_cfg;
-extern void lustre_swab_portals_cfg(struct portals_cfg *pcfg);
-
struct lustre_cfg;
extern void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg);
struct config_llog_instance {
char * cfg_instance;
struct obd_uuid cfg_uuid;
- ptl_nid_t cfg_local_nid;
};
int class_config_parse_llog(struct llog_ctxt *ctxt, char *name,
struct config_llog_instance *cfg);
RETURN(rc);
}
-int
-kportal_nal_cmd(struct portals_cfg *pcfg)
-{
- /* handle portals command if we want */
- return 0;
-}
-
extern int class_handle_ioctl(unsigned int cmd, unsigned long arg);
-int lib_ioctl_nalcmd(int dev_id, int opc, void * ptr)
-{
- struct portal_ioctl_data *ptldata;
-
- if (opc == IOC_PORTAL_NAL_CMD) {
- ptldata = (struct portal_ioctl_data *) ptr;
-
- if (ptldata->ioc_nal_cmd == NAL_CMD_REGISTER_MYNID) {
- tcpnal_mynid = ptldata->ioc_nid;
- printf("mynid: %u.%u.%u.%u\n",
- (unsigned)(tcpnal_mynid>>24) & 0xFF,
- (unsigned)(tcpnal_mynid>>16) & 0xFF,
- (unsigned)(tcpnal_mynid>>8) & 0xFF,
- (unsigned)(tcpnal_mynid) & 0xFF);
- }
- }
-
- return (0);
-}
-
int lib_ioctl(int dev_id, int opc, void * ptr)
{
int rc;
int lllib_init(char *dumpfile)
{
- if (!g_zconf) {
- /* this parse only get my nid from config file
- * before initialize portals
- */
- if (parse_dump(dumpfile, lib_ioctl_nalcmd))
- return -1;
- } else {
+ if (g_zconf) {
/* XXX need setup mynid before tcpnal initialize */
tcpnal_mynid = ((uint64_t)getpid() << 32) | time(0);
printf("LibLustre: TCPNAL NID: %016llx\n", tcpnal_mynid);
struct obd_uuid mdc_uuid;
struct llog_ctxt *ctxt;
ptl_nid_t nid = 0;
- int nal, err, rc = 0;
+ int err, rc = 0;
ENTRY;
generate_random_uuid(uuid);
class_uuid_unparse(uuid, &mdc_uuid);
- if (ptl_parse_nid(&nid, g_zconf_mdsnid)) {
+ nid = libcfs_str2nid(g_zconf_mdsnid);
+ if (nid == PTL_NID_ANY) {
CERROR("Can't parse NID %s\n", g_zconf_mdsnid);
RETURN(-EINVAL);
}
- nal = ptl_name2nal("tcp");
- if (nal <= 0) {
- CERROR("Can't parse NAL tcp\n");
- RETURN(-EINVAL);
- }
-
lustre_cfg_bufs_reset(&bufs, NULL);
lustre_cfg_bufs_set_string(&bufs, 1, peer);
lcfg = lustre_cfg_new(LCFG_ADD_UUID, &bufs);
lcfg->lcfg_nid = nid;
- lcfg->lcfg_nal = nal;
err = class_process_config(lcfg);
lustre_cfg_free(lcfg);
if (err < 0)
return NULL;
}
-/* XXX move to proper place */
-#error
-char *portals_nid2str(int nal, ptl_nid_t nid, char *str)
-{
- switch(nal){
- case TCPNAL:
- /* userspace NAL */
- case SOCKNAL:
- snprintf(str, PTL_NALFMT_SIZE - 1, "%u:%u.%u.%u.%u",
- (__u32)(nid >> 32), HIPQUAD(nid));
- break;
- case QSWNAL:
- case GMNAL:
- case IBNAL:
- case SCIMACNAL:
- snprintf(str, PTL_NALFMT_SIZE - 1, "%u:%u",
- (__u32)(nid >> 32), (__u32)nid);
- break;
- default:
- snprintf(str, PTL_NALFMT_SIZE - 1, "?%d? %llx",
- nal, (long long)nid);
- break;
- }
- return str;
-}
-
-struct pingcli_args {
- ptl_nid_t mynid;
- ptl_nid_t nid;
- ptl_pid_t port;
- int count;
- int size;
-};
-
struct task_struct *current;
-/* portals interfaces */
-int
-kportal_nal_cmd(struct portals_cfg *pcfg)
-{
-#if 0
- __u32 nal = pcfg->pcfg_nal;
- int rc = -EINVAL;
-
- ENTRY;
-
- down(&nal_cmd_sem);
- if (nal > 0 && nal <= NAL_MAX_NR && nal_cmd[nal].nch_handler) {
- CDEBUG(D_IOCTL, "calling handler nal: %d, cmd: %d\n", nal,
- pcfg->pcfg_command);
- rc = nal_cmd[nal].nch_handler(pcfg, nal_cmd[nal].nch_private);
- }
- up(&nal_cmd_sem);
- RETURN(rc);
-#else
- CERROR("empty function!!!\n");
- return 0;
-#endif
-}
-
int init_current(int argc, char **argv)
{
current = malloc(sizeof(*current));
char *peer = "ECHO_PEER_NID";
class_uuid_t osc_uuid, echo_uuid;
struct obd_uuid osc_uuid_str, echo_uuid_str;
- int nal, err;
+ int err;
ENTRY;
generate_random_uuid(osc_uuid);
generate_random_uuid(echo_uuid);
class_uuid_unparse(echo_uuid, &echo_uuid_str);
- if (ptl_parse_nid(&nid, echo_server_nid)) {
+ nid = libcfs_str2nid(echo_server_nid);
+ if (nid == PTL_NID_ANY) {
CERROR("Can't parse NID %s\n", echo_server_nid);
RETURN(-EINVAL);
}
- nal = ptl_name2nal("tcp");
- if (nal <= 0) {
- CERROR("Can't parse NAL tcp\n");
- RETURN(-EINVAL);
- }
/* add uuid */
lustre_cfg_bufs_reset(&bufs, NULL);
lustre_cfg_bufs_set_string(&bufs, 1, peer);
lcfg = lustre_cfg_new(LCFG_ADD_UUID, &bufs);
lcfg->lcfg_nid = nid;
- lcfg->lcfg_nal = nal;
err = class_process_config(lcfg);
lustre_cfg_free(lcfg);
if (err < 0) {
{
struct lustre_cfg *lcfg = NULL;
struct lustre_cfg_bufs bufs;
- struct portals_cfg pcfg;
char * peer = "MDS_PEER_UUID";
struct obd_device *obd;
struct lustre_handle mdc_conn = {0, };
class_uuid_unparse(uuid, &mdc_uuid);
CDEBUG(D_HA, "generated uuid: %s\n", mdc_uuid.uuid);
- if (lmd->lmd_local_nid) {
- PCFG_INIT(pcfg, NAL_CMD_REGISTER_MYNID);
- pcfg.pcfg_nal = lmd->lmd_nal;
- pcfg.pcfg_nid = lmd->lmd_local_nid;
- err = libcfs_nal_cmd(&pcfg);
- if (err <0)
- GOTO(out, err);
- }
-
- if (lmd->lmd_nal == SOCKNAL ||
- lmd->lmd_nal == OPENIBNAL ||
- lmd->lmd_nal == IIBNAL ||
- lmd->lmd_nal == VIBNAL ||
- lmd->lmd_nal == RANAL) {
- PCFG_INIT(pcfg, NAL_CMD_ADD_PEER);
- pcfg.pcfg_nal = lmd->lmd_nal;
- pcfg.pcfg_nid = lmd->lmd_server_nid;
- pcfg.pcfg_id = lmd->lmd_server_ipaddr;
- pcfg.pcfg_misc = lmd->lmd_port;
- err = libcfs_nal_cmd(&pcfg);
- if (err <0)
- GOTO(out, err);
- }
-
lustre_cfg_bufs_reset(&bufs, name);
lustre_cfg_bufs_set_string(&bufs, 1, peer);
lcfg = lustre_cfg_new(LCFG_ADD_UUID, &bufs);
- lcfg->lcfg_nal = lmd->lmd_nal;
- lcfg->lcfg_nid = lmd->lmd_server_nid;
- LASSERT(lcfg->lcfg_nal);
- LASSERT(lcfg->lcfg_nid);
+ lcfg->lcfg_nid = lmd->lmd_nid;
+ LASSERT(lcfg->lcfg_nid != PTL_NID_ANY);
err = class_process_config(lcfg);
lustre_cfg_free(lcfg);
if (err < 0)
- GOTO(out_del_conn, err);
+ GOTO(out, err);
lustre_cfg_bufs_reset(&bufs, name);
lustre_cfg_bufs_set_string(&bufs, 1, LUSTRE_MDC_NAME);
err = class_process_config(lcfg);
lustre_cfg_free(lcfg);
-out_del_conn:
- if (lmd->lmd_nal == SOCKNAL ||
- lmd->lmd_nal == OPENIBNAL ||
- lmd->lmd_nal == IIBNAL ||
- lmd->lmd_nal == VIBNAL ||
- lmd->lmd_nal == RANAL) {
- PCFG_INIT(pcfg, NAL_CMD_DEL_PEER);
- pcfg.pcfg_nal = lmd->lmd_nal;
- pcfg.pcfg_nid = lmd->lmd_server_nid;
- pcfg.pcfg_flags = 1; /* single_share */
- err = libcfs_nal_cmd(&pcfg);
- if (err <0)
- GOTO(out, err);
- }
out:
if (rc == 0)
rc = err;
cfg.cfg_instance = sbi->ll_instance;
cfg.cfg_uuid = sbi->ll_sb_uuid;
- cfg.cfg_local_nid = lmd->lmd_local_nid;
err = lustre_process_log(lmd, lmd->lmd_profile, &cfg, 0);
if (err < 0) {
CERROR("Unable to process log: %s\n", lmd->lmd_profile);
if (data->ioc_type == LUSTRE_CFG_TYPE) {
rec.lrh_type = OBD_CFG_REC;
- } else if (data->ioc_type == PORTALS_CFG_TYPE) {
- rec.lrh_type = PTL_CFG_REC;
} else {
CERROR("unknown cfg record type:%d \n", data->ioc_type);
RETURN(-EINVAL);
case MDS_UNLINK_REC:
case MDS_SETATTR_REC:
case OBD_CFG_REC:
- case PTL_CFG_REC:
case LLOG_HDR_MAGIC: {
l = snprintf(out, remains, "[index]: %05d [type]: "
"%02x [len]: %04d ok\n",
case MDS_SETATTR_REC: {
struct llog_setattr_rec *lsr = (struct llog_setattr_rec *)rec;
-
+
__swab64s(&lsr->lsr_oid);
__swab32s(&lsr->lsr_ogen);
__swab32s(&lsr->lsr_uid);
__swab32s(&lsr->lsr_gid);
-
+
break;
}
case OBD_CFG_REC:
- case PTL_CFG_REC:
/* these are swabbed as they are consumed */
break;
}
EXPORT_SYMBOL(lustre_swab_llog_hdr);
-#define PRINT_PCFG32(x) CDEBUG(D_OTHER, "\tpcfg->pcfg_"#x": %#x\n", pcfg->pcfg_##x)
-#define PRINT_PCFG64(x) CDEBUG(D_OTHER, "\tpcfg->pcfg_"#x": "LPX64"\n", pcfg->pcfg_##x)
-
-static void print_portals_cfg(struct portals_cfg *pcfg)
-{
- ENTRY;
-
- if (!(portal_debug & D_OTHER)) /* don't loop on nothing */
- return;
- CDEBUG(D_OTHER, "portals_cfg: %p\n", pcfg);
- PRINT_PCFG32(version);
- PRINT_PCFG32(command);
-
- PRINT_PCFG32(nal);
- PRINT_PCFG32(flags);
-
- PRINT_PCFG32(gw_nal);
- PRINT_PCFG64(nid);
- PRINT_PCFG64(nid2);
- PRINT_PCFG64(nid3);
- PRINT_PCFG32(id);
- PRINT_PCFG32(misc);
- PRINT_PCFG32(fd);
- PRINT_PCFG32(count);
- PRINT_PCFG32(size);
- PRINT_PCFG32(wait);
-
- PRINT_PCFG32(plen1);
- PRINT_PCFG32(plen2);
-
- EXIT;
-}
-
-void lustre_swab_portals_cfg(struct portals_cfg *pcfg)
-{
- ENTRY;
-
- __swab32s(&pcfg->pcfg_version);
- __swab32s(&pcfg->pcfg_command);
-
- __swab32s(&pcfg->pcfg_nal);
- __swab32s(&pcfg->pcfg_flags);
-
- __swab32s(&pcfg->pcfg_gw_nal);
- __swab64s(&pcfg->pcfg_nid);
- __swab64s(&pcfg->pcfg_nid2);
- __swab64s(&pcfg->pcfg_nid3);
- __swab32s(&pcfg->pcfg_id);
- __swab32s(&pcfg->pcfg_misc);
- __swab32s(&pcfg->pcfg_fd);
- __swab32s(&pcfg->pcfg_count);
- __swab32s(&pcfg->pcfg_size);
- __swab32s(&pcfg->pcfg_wait);
-
- __swab32s(&pcfg->pcfg_plen1);
- __swab32s(&pcfg->pcfg_plen2);
-
- print_portals_cfg(pcfg);
- EXIT;
-}
-EXPORT_SYMBOL(lustre_swab_portals_cfg);
-
static void print_lustre_cfg(struct lustre_cfg *lcfg)
{
int i;
CDEBUG(D_OTHER, "\tlcfg->lcfg_num: %#x\n", lcfg->lcfg_num);
CDEBUG(D_OTHER, "\tlcfg->lcfg_flags: %#x\n", lcfg->lcfg_flags);
CDEBUG(D_OTHER, "\tlcfg->lcfg_nid: "LPX64"\n", lcfg->lcfg_nid);
- CDEBUG(D_OTHER, "\tlcfg->lcfg_nal: %#x\n", lcfg->lcfg_nal);
CDEBUG(D_OTHER, "\tlcfg->lcfg_bufcount: %d\n", lcfg->lcfg_bufcount);
if (lcfg->lcfg_bufcount < LUSTRE_CFG_MAX_BUFCOUNT)
__swab32s(&lcfg->lcfg_num);
__swab32s(&lcfg->lcfg_flags);
__swab64s(&lcfg->lcfg_nid);
- __swab32s(&lcfg->lcfg_nal);
__swab32s(&lcfg->lcfg_bufcount);
for (i = 0; i < lcfg->lcfg_bufcount && i < LUSTRE_CFG_MAX_BUFCOUNT; i++)
GOTO(out, err);
}
case LCFG_ADD_UUID: {
- CDEBUG(D_IOCTL, "adding mapping from uuid %s to nid "LPX64
- " (%s), nal %x\n", lustre_cfg_string(lcfg, 1),
- lcfg->lcfg_nid, libcfs_nid2str(lcfg->lcfg_nid),
- lcfg->lcfg_nal);
+ CDEBUG(D_IOCTL, "adding mapping: uuid %s -> nid %s("LPX64")\n",
+ lustre_cfg_string(lcfg, 1),
+ libcfs_nid2str(lcfg->lcfg_nid), lcfg->lcfg_nid);
err = class_add_uuid(lustre_cfg_string(lcfg, 1), lcfg->lcfg_nid);
GOTO(out, err);
lcfg_new->lcfg_num = lcfg->lcfg_num;
lcfg_new->lcfg_flags = lcfg->lcfg_flags;
lcfg_new->lcfg_nid = lcfg->lcfg_nid;
- lcfg_new->lcfg_nal = lcfg->lcfg_nal;
rc = class_process_config(lcfg_new);
lustre_cfg_free(lcfg_new);
OBD_FREE(inst_name, inst_len);
break;
}
- case PTL_CFG_REC: {
- struct portals_cfg *pcfg = (struct portals_cfg *)cfg_buf;
- if (pcfg->pcfg_version != PORTALS_CFG_VERSION) {
- if (pcfg->pcfg_version == __swab32(PORTALS_CFG_VERSION)) {
- CDEBUG(D_OTHER, "swabbing portals_cfg %p\n",
- pcfg);
- lustre_swab_portals_cfg(pcfg);
- } else {
- CERROR("Unknown portals_cfg version: %#x "
- "(expecting %#x)\n",
- pcfg->pcfg_version,
- PORTALS_CFG_VERSION);
- RETURN(-EINVAL);
- }
- }
- if (pcfg->pcfg_command ==NAL_CMD_REGISTER_MYNID &&
- cfg->cfg_local_nid != PTL_NID_ANY) {
- pcfg->pcfg_nid = cfg->cfg_local_nid;
- }
-
- rc = libcfs_nal_cmd(pcfg);
- break;
- }
default:
CERROR("Unknown llog record type %#x encountered\n",
rec->lrh_type);
if (lcfg->lcfg_nid)
CDEBUG(D_INFO, " nid: "LPX64"\n",
lcfg->lcfg_nid);
- if (lcfg->lcfg_nal)
- CDEBUG(D_INFO, " nal: %x\n", lcfg->lcfg_nal);
if (lcfg->lcfg_num)
CDEBUG(D_INFO, " nal: %x\n", lcfg->lcfg_num);
for (i = 1; i < lcfg->lcfg_bufcount; i++)
if (LUSTRE_CFG_BUFLEN(lcfg, i) > 0)
CDEBUG(D_INFO, " inlbuf%d: %s\n", i,
lustre_cfg_string(lcfg, i));
- } else if (rec->lrh_type == PTL_CFG_REC) {
- struct portals_cfg *pcfg = (struct portals_cfg *)cfg_buf;
- CDEBUG(D_INFO, "pcfg command: %d\n", pcfg->pcfg_command);
- if (pcfg->pcfg_nal)
- CDEBUG(D_INFO, " nal: %x\n",
- pcfg->pcfg_nal);
- if (pcfg->pcfg_gw_nal)
- CDEBUG(D_INFO, " gw_nal: %x\n",
- pcfg->pcfg_gw_nal);
- if (pcfg->pcfg_nid)
- CDEBUG(D_INFO, " nid: "LPX64"\n",
- pcfg->pcfg_nid);
- if (pcfg->pcfg_nid2)
- CDEBUG(D_INFO, " nid: "LPX64"\n",
- pcfg->pcfg_nid2);
- if (pcfg->pcfg_nid3)
- CDEBUG(D_INFO, " nid: "LPX64"\n",
- pcfg->pcfg_nid3);
- if (pcfg->pcfg_misc)
- CDEBUG(D_INFO, " nid: %d\n",
- pcfg->pcfg_misc);
- if (pcfg->pcfg_id)
- CDEBUG(D_INFO, " id: %x\n",
- pcfg->pcfg_id);
- if (pcfg->pcfg_flags)
- CDEBUG(D_INFO, " flags: %x\n",
- pcfg->pcfg_flags);
} else {
CERROR("unhandled lrh_type: %#x\n", rec->lrh_type);
rc = -EINVAL;
(long long)MDS_SETATTR_REC);
LASSERTF(OBD_CFG_REC == 274857984, " found %lld\n",
(long long)OBD_CFG_REC);
- LASSERTF(PTL_CFG_REC == 274923520, " found %lld\n",
- (long long)PTL_CFG_REC);
LASSERTF(LLOG_GEN_REC == 274989056, " found %lld\n",
(long long)LLOG_GEN_REC);
LASSERTF(LLOG_HDR_MAGIC == 275010873, " found %lld\n",
def network(self, net, nid):
""" set mynid """
cmds = """
- network %s
- mynid %s
- quit """ % (net, nid)
- self.run(cmds)
+ network %s
+ mynid %s
+ quit """ % (net, nid)
+ self.run(cmds)
# add an interface
def add_interface(self, net, ip, netmask = ""):
""" add an interface """
- cmds = """
- network %s
- add_interface %s %s
- quit """ % (net, ip, netmask)
- self.run(cmds)
+# cmds = """
+# network %s
+# add_interface %s %s
+# quit """ % (net, ip, netmask)
+# self.run(cmds)
# delete an interface
def del_interface(self, net, ip):
""" delete an interface """
- cmds = """
- network %s
- del_interface %s
- quit """ % (net, ip)
- self.run(cmds)
+# cmds = """
+# network %s
+# del_interface %s
+# quit """ % (net, ip)
+# self.run(cmds)
# create a new connection
def add_uuid(self, net_type, uuid, nid):
- cmds = "\n add_uuid %s %s %s" %(uuid, nid, net_type)
+ cmds = "\n add_uuid %s %s@%s" %(uuid, nid, net_type)
self.run(cmds)
def add_peer(self, net_type, nid, hostaddr, port):
- if net_type in ('tcp','openib','ra') and not config.lctl_dump:
- cmds = """
- network %s
- add_peer %s %s %d
- quit""" % (net_type,
- nid, hostaddr, port )
- self.run(cmds)
- elif net_type in ('iib',) and not config.lctl_dump:
- cmds = """
- network %s
- add_peer %s
- quit""" % (net_type,
- nid )
- self.run(cmds)
- elif net_type in ('vib',) and not config.lctl_dump:
- cmds = """
- network %s
- add_peer %s %s
- quit""" % (net_type,
- nid, hostaddr )
- self.run(cmds)
+# if net_type in ('tcp','openib','ra') and not config.lctl_dump:
+# cmds = """
+# network %s
+# add_peer %s %s %d
+# quit""" % (net_type,
+# nid, hostaddr, port )
+# self.run(cmds)
+# elif net_type in ('iib',) and not config.lctl_dump:
+# cmds = """
+# network %s
+# add_peer %s
+# quit""" % (net_type,
+# nid )
+# self.run(cmds)
+# elif net_type in ('vib',) and not config.lctl_dump:
+# cmds = """
+# network %s
+# add_peer %s %s
+# quit""" % (net_type,
+# nid, hostaddr )
+# self.run(cmds)
def connect(self, srv):
self.add_uuid(srv.net_type, srv.nid_uuid, srv.nid)
- if srv.net_type in ('tcp','openib','iib','vib','ra') and not config.lctl_dump:
- if srv.hostaddr[0]:
- hostaddr = string.split(srv.hostaddr[0], '/')[0]
- self.add_peer(srv.net_type, srv.nid, hostaddr, srv.port)
+# if srv.net_type in ('tcp','openib','iib','vib','ra') and not config.lctl_dump:
+# if srv.hostaddr[0]:
+# hostaddr = string.split(srv.hostaddr[0], '/')[0]
+# self.add_peer(srv.net_type, srv.nid, hostaddr, srv.port)
# Recover a device
def recover(self, dev_name, new_conn):
# add a route to a range
def add_route(self, net, gw, lo, hi):
- cmds = """
- network %s
- add_route %s %s %s
- quit """ % (net,
- gw, lo, hi)
- try:
- self.run(cmds)
- except CommandError, e:
- log ("ignore: ")
- e.dump()
+# cmds = """
+# network %s
+# add_route %s %s %s
+# quit """ % (net,
+# gw, lo, hi)
+# try:
+# self.run(cmds)
+# except CommandError, e:
+# log ("ignore: ")
+# e.dump()
def del_route(self, net, gw, lo, hi):
- cmds = """
- ignore_errors
- network %s
- del_route %s %s %s
- quit """ % (net, gw, lo, hi)
- self.run(cmds)
+# cmds = """
+# ignore_errors
+# network %s
+# del_route %s %s %s
+# quit """ % (net, gw, lo, hi)
+# self.run(cmds)
# add a route to a host
def add_route_host(self, net, uuid, gw, tgt):
- self.add_uuid(net, uuid, tgt)
- cmds = """
- network %s
- add_route %s %s
- quit """ % (net,
- gw, tgt)
- try:
- self.run(cmds)
- except CommandError, e:
- log ("ignore: ")
- e.dump()
+# self.add_uuid(net, uuid, tgt)
+# cmds = """
+# network %s
+# add_route %s %s
+# quit """ % (net,
+# gw, tgt)
+# try:
+# self.run(cmds)
+# except CommandError, e:
+# log ("ignore: ")
+# e.dump()
# add a route to a range
def del_route_host(self, net, uuid, gw, tgt):
- self.del_uuid(uuid)
- cmds = """
- ignore_errors
- network %s
- del_route %s %s
- quit """ % (net, gw, tgt)
- self.run(cmds)
+# self.del_uuid(uuid)
+# cmds = """
+# ignore_errors
+# network %s
+# del_route %s %s
+# quit """ % (net, gw, tgt)
+# self.run(cmds)
def del_peer(self, net_type, nid, hostaddr):
- if net_type in ('tcp',) and not config.lctl_dump:
- cmds = """
- ignore_errors
- network %s
- del_peer %s %s single_share
- quit""" % (net_type,
- nid, hostaddr)
- self.run(cmds)
- elif net_type in ('openib','iib','vib','ra') and not config.lctl_dump:
- cmds = """
- ignore_errors
- network %s
- del_peer %s single_share
- quit""" % (net_type,
- nid)
- self.run(cmds)
+# if net_type in ('tcp',) and not config.lctl_dump:
+# cmds = """
+# ignore_errors
+# network %s
+# del_peer %s %s single_share
+# quit""" % (net_type,
+# nid, hostaddr)
+# self.run(cmds)
+# elif net_type in ('openib','iib','vib','ra') and not config.lctl_dump:
+# cmds = """
+# ignore_errors
+# network %s
+# del_peer %s single_share
+# quit""" % (net_type,
+# nid)
+# self.run(cmds)
# disconnect one connection
- def disconnect(self, srv):
- self.del_uuid(srv.nid_uuid)
- if srv.net_type in ('tcp','openib','iib','vib','ra') and not config.lctl_dump:
- if srv.hostaddr[0]:
- hostaddr = string.split(srv.hostaddr[0], '/')[0]
- self.del_peer(srv.net_type, srv.nid, hostaddr)
+# def disconnect(self, srv):
+# self.del_uuid(srv.nid_uuid)
+# if srv.net_type in ('tcp','openib','iib','vib','ra') and not config.lctl_dump:
+# if srv.hostaddr[0]:
+# hostaddr = string.split(srv.hostaddr[0], '/')[0]
+# self.del_peer(srv.net_type, srv.nid, hostaddr)
def del_uuid(self, uuid):
cmds = """
# disconnect all
def disconnectAll(self, net):
- cmds = """
- ignore_errors
- network %s
- disconnect
- quit""" % (net)
- self.run(cmds)
+# cmds = """
+# ignore_errors
+# network %s
+# disconnect
+# quit""" % (net)
+# self.run(cmds)
def attach(self, type, name, uuid):
cmds = """
{"==== network config ====", jt_noop, 0, "network config"},
{"--net", jt_opt_net, 0, "run <command> after setting network to <net>\n"
"usage: --net <tcp/elan/myrinet> <command>"},
- {"network", jt_ptl_network, 0, "commands that follow apply to net\n"
- "usage: network <tcp/elan/myrinet>"},
+ {"network", jt_ptl_network, 0, "show local NIDs; with arg set current\n"
+ "usage: network [tcp|elan|ra...]"},
{"interface_list", jt_ptl_print_interfaces,0,"print interface entries\n"
"usage: interface_list"},
{"add_interface", jt_ptl_add_interface, 0, "add interface entry\n"
"The nid defaults to hostname for tcp networks and is automatically "
"setup for elan/myrinet networks.\n"
"usage: mynid [<nid>]"},
- {"shownid", jt_ptl_shownid, 0, "print the local NID\n"
- "usage: shownid"},
{"add_uuid", jt_lcfg_add_uuid, 0, "associate a UUID with a nid\n"
"usage: add_uuid <uuid> <nid> <net_type>"},
{"close_uuid", jt_obd_close_uuid, 0, "disconnect a UUID\n"
#include "obdctl.h"
#include <portals/ptlctl.h>
-int verbose;
-int nomtab;
-int fake;
-int force;
+int verbose;
+int nomtab;
+int fake;
+int force;
static char *progname = NULL;
-typedef struct {
- ptl_nid_t gw;
- ptl_nid_t lo;
- ptl_nid_t hi;
-} llmount_route_t;
-
-#define MAX_ROUTES 1024
-int route_index;
-ptl_nid_t lmd_cluster_id = 0;
-llmount_route_t routes[MAX_ROUTES];
-
void usage(FILE *out)
{
fprintf(out, "usage: %s <mdsnode>:/<mdsname>/<cfgname> <mountpt> "
"[-fhnv] [-o mntopt]\n", progname);
- fprintf(out, "\t<mdsnode>: hostname or nid of MDS (config) node\n"
+ fprintf(out, "\t<mdsnode>: nid of MDS (config) node\n"
"\t<mdsname>: name of MDS service (e.g. mds1)\n"
"\t<cfgname>: name of client config (e.g. client)\n"
"\t<mountpt>: filesystem mountpoint (e.g. /mnt/lustre)\n"
"\t--force: force mount even if already in /etc/mtab\n"
"\t-h|--help: print this usage message\n"
"\t-n|--nomtab: do not update /etc/mtab after mount\n"
- "\t-v|--verbose: print verbose config settings\n"
- "\t-o: filesystem mount options:\n"
- "\t\tnettype={tcp,elan,iibnal,lonal}: network type\n"
- "\t\tcluster_id=0xNNNN: cluster this node is part of\n"
- "\t\tlocal_nid=0xNNNN: client ID (default ipaddr or nodenum)\n"
- "\t\tserver_nid=0xNNNN: server node ID (default mdsnode)\n"
- "\t\tport=NNN: server port (default 988 for tcp)\n"
- "\t\troute=<gw>[-<gw>]:<low>[-<high>]: portal route to MDS\n");
+ "\t-v|--verbose: print verbose config settings\n");
exit(out != stdout);
}
{
memset(lmd, 0, sizeof(*lmd));
lmd->lmd_magic = LMD_MAGIC;
- lmd->lmd_server_nid = PTL_NID_ANY;
- lmd->lmd_local_nid = PTL_NID_ANY;
- lmd->lmd_port = 988; /* XXX define LUSTRE_DEFAULT_PORT */
- lmd->lmd_nal = SOCKNAL;
+ lmd->lmd_nid = PTL_NID_ANY;
return 0;
}
int
print_options(struct lustre_mount_data *lmd)
{
- int i;
-
+ printf("nid: %s\n", libcfs_nid2str(lmd->lmd_nid));
printf("mds: %s\n", lmd->lmd_mds);
printf("profile: %s\n", lmd->lmd_profile);
- printf("server_nid: "LPX64"\n", lmd->lmd_server_nid);
- printf("local_nid: "LPX64"\n", lmd->lmd_local_nid);
- printf("nal: %x\n", lmd->lmd_nal);
- printf("server_ipaddr: 0x%x\n", lmd->lmd_server_ipaddr);
- printf("port: %d\n", lmd->lmd_port);
-
- for (i = 0; i < route_index; i++)
- printf("route: "LPX64" : "LPX64" - "LPX64"\n",
- routes[i].gw, routes[i].lo, routes[i].hi);
-
return 0;
}
-static int parse_route(char *opteq, char *opttgts)
-{
- char *gw_lo_ptr, *gw_hi_ptr, *tgt_lo_ptr, *tgt_hi_ptr;
- ptl_nid_t gw_lo, gw_hi, tgt_lo, tgt_hi;
-
- opttgts[0] = '\0';
- gw_lo_ptr = opteq + 1;
- if (!(gw_hi_ptr = strchr(gw_lo_ptr, '-'))) {
- gw_hi_ptr = gw_lo_ptr;
- } else {
- gw_hi_ptr[0] = '\0';
- gw_hi_ptr++;
- }
-
- if (ptl_parse_nid(&gw_lo, gw_lo_ptr) != 0) {
- fprintf(stderr, "%s: can't parse NID %s\n", progname,gw_lo_ptr);
- return(1);
- }
-
- if (ptl_parse_nid(&gw_hi, gw_hi_ptr) != 0) {
- fprintf(stderr, "%s: can't parse NID %s\n", progname,gw_hi_ptr);
- return(1);
- }
-
- tgt_lo_ptr = opttgts + 1;
- if (!(tgt_hi_ptr = strchr(tgt_lo_ptr, '-'))) {
- tgt_hi_ptr = tgt_lo_ptr;
- } else {
- tgt_hi_ptr[0] = '\0';
- tgt_hi_ptr++;
- }
-
- if (ptl_parse_nid(&tgt_lo, tgt_lo_ptr) != 0) {
- fprintf(stderr, "%s: can't parse NID %s\n",progname,tgt_lo_ptr);
- return(1);
- }
-
- if (ptl_parse_nid(&tgt_hi, tgt_hi_ptr) != 0) {
- fprintf(stderr, "%s: can't parse NID %s\n",progname,tgt_hi_ptr);
- return(1);
- }
-
- while (gw_lo <= gw_hi) {
- if (route_index >= MAX_ROUTES) {
- fprintf(stderr, "%s: to many routes %d\n",
- progname, MAX_ROUTES);
- return(-1);
- }
-
- routes[route_index].gw = gw_lo;
- routes[route_index].lo = tgt_lo;
- routes[route_index].hi = tgt_hi;
- route_index++;
- gw_lo++;
- }
-
- return(0);
-}
-
/*****************************************************************************
*
* This part was cribbed from util-linux/mount/mount.c. There was no clear
int parse_options(char *options, struct lustre_mount_data *lmd, int *flagp)
{
- ptl_nid_t nid = 0, cluster_id = 0;
int val;
- char *opt, *opteq, *opttgts;
+ char *opt, *opteq;
*flagp = 0;
/* parsing ideas here taken from util-linux/mount/nfsmount.c */
if ((opteq = strchr(opt, '='))) {
val = atoi(opteq + 1);
*opteq = '\0';
- if (!strcmp(opt, "nettype")) {
- lmd->lmd_nal = ptl_name2nal(opteq + 1);
- if (lmd->lmd_nal < 0) {
- fprintf(stderr, "%s: can't parse NET "
- "%s\n", progname, opteq + 1);
- return (1);
- }
- } else if(!strcmp(opt, "cluster_id")) {
- if (ptl_parse_nid(&cluster_id, opteq+1) != 0) {
- fprintf(stderr, "%s: can't parse NID "
- "%s\n", progname, opteq+1);
- return (1);
- }
- lmd_cluster_id = cluster_id;
- } else if(!strcmp(opt, "route")) {
- if (!(opttgts = strchr(opteq + 1, ':'))) {
- fprintf(stderr, "%s: Route must be "
- "of the form: route="
- "<gw>[-<gw>]:<low>[-<high>]\n",
- progname);
- return(1);
- }
- parse_route(opteq, opttgts);
- } else if (!strcmp(opt, "local_nid")) {
- if (ptl_parse_nid(&nid, opteq + 1) != 0) {
- fprintf(stderr, "%s: "
- "can't parse NID %s\n",
- progname,
- opteq+1);
- return (1);
- }
- lmd->lmd_local_nid = nid;
- } else if (!strcmp(opt, "server_nid")) {
- if (ptl_parse_nid(&nid, opteq + 1) != 0) {
- fprintf(stderr, "%s: "
- "can't parse NID %s\n",
- progname, opteq + 1);
- return (1);
- }
- lmd->lmd_server_nid = nid;
- } else if (!strcmp(opt, "port")) {
- lmd->lmd_port = val;
+ if (0) {
+ /* All the network options have gone :)) */
} else {
fprintf(stderr, "%s: unknown option '%s'\n",
progname, opt);
}
int
-get_local_elan_id(char *fname, char *buf)
-{
- FILE *fp = fopen(fname, "r");
- int rc;
-
- if (fp == NULL)
- return 1;
-
- rc = fscanf(fp, "NodeId %255s", buf);
-
- fclose(fp);
-
- return (rc == 1) ? 0 : -1;
-}
-
-int
-set_local(struct lustre_mount_data *lmd)
-{
- /* XXX ClusterID?
- * XXX PtlGetId() will be safer if portals is loaded and
- * initialised correctly at this time... */
- char buf[256], *ptr = buf;
- ptl_nid_t nid;
- int rc;
-
- if (lmd->lmd_local_nid != PTL_NID_ANY)
- return 0;
-
- memset(buf, 0, sizeof(buf));
-
- switch (lmd->lmd_nal) {
- default:
- fprintf(stderr, "%s: Unknown network type: %d\n",
- progname, lmd->lmd_nal);
- return 1;
-
- case SOCKNAL:
- /* We need to do this before the mount is started if routing */
- system("/sbin/modprobe ksocknal");
- case OPENIBNAL:
- case IIBNAL:
- case VIBNAL:
- case RANAL:
- rc = gethostname(buf, sizeof(buf) - 1);
- if (rc) {
- fprintf (stderr, "%s: can't get local buf: %d\n",
- progname, rc);
- return rc;
- }
- break;
- case QSWNAL: {
- char *pfiles[] = {"/proc/qsnet/elan3/device0/position",
- "/proc/qsnet/elan4/device0/position",
- "/proc/elan/device0/position",
- NULL};
- int i = 0;
-
- /* We need to do this before the mount is started if routing */
- system("/sbin/modprobe kqswnal");
- do {
- rc = get_local_elan_id(pfiles[i], buf);
- } while (rc != 0 && pfiles[++i] != NULL);
-
- if (rc != 0) {
- rc = gethostname(buf, sizeof(buf) - 1);
- if (rc == 0) {
- char *tmp = ptr;
- while ((*tmp >= 'a' && *tmp <= 'z') ||
- (*tmp >= 'A' && *tmp <= 'Z'))
- tmp++;
- ptr = strsep(&tmp, ".");
- } else {
- fprintf(stderr,
- "%s: can't read Elan ID from /proc\n",
- progname);
- return 1;
- }
- }
- break;
- }
- }
-
- if (ptl_parse_nid (&nid, ptr) != 0) {
- fprintf (stderr, "%s: can't parse NID %s\n", progname, buf);
- return (1);
- }
-
- lmd->lmd_local_nid = nid + lmd_cluster_id;
- return 0;
-}
-
-int
-set_peer(char *hostname, struct lustre_mount_data *lmd)
-{
- ptl_nid_t nid = 0;
- int rc;
-
- switch (lmd->lmd_nal) {
- default:
- fprintf(stderr, "%s: Unknown network type: %d\n",
- progname, lmd->lmd_nal);
- return 1;
-
- case IIBNAL:
- if (lmd->lmd_server_nid != PTL_NID_ANY)
- break;
- if (ptl_parse_nid (&nid, hostname) != 0) {
- fprintf (stderr, "%s: can't parse NID %s\n",
- progname, hostname);
- return (1);
- }
- lmd->lmd_server_nid = nid;
- break;
-
- case SOCKNAL:
- case OPENIBNAL:
- case VIBNAL:
- case RANAL:
- if (lmd->lmd_server_nid == PTL_NID_ANY) {
- if (ptl_parse_nid (&nid, hostname) != 0) {
- fprintf (stderr, "%s: can't parse NID %s\n",
- progname, hostname);
- return (1);
- }
- lmd->lmd_server_nid = nid;
- }
-
- if (ptl_parse_ipaddr(&lmd->lmd_server_ipaddr, hostname) != 0) {
- fprintf (stderr, "%s: can't parse host %s\n",
- progname, hostname);
- return (1);
- }
- break;
- case QSWNAL: {
- char buf[64];
-
- if (lmd->lmd_server_nid != PTL_NID_ANY)
- break;
-
- rc = sscanf(hostname, "%*[^0-9]%63[0-9]", buf);
- if (rc != 1) {
- fprintf (stderr, "%s: can't get elan id from host %s\n",
- progname, hostname);
- return 1;
- }
- if (ptl_parse_nid (&nid, buf) != 0) {
- fprintf (stderr, "%s: can't parse NID %s\n",
- progname, hostname);
- return (1);
- }
- lmd->lmd_server_nid = nid;
-
- break;
- }
- }
-
- return 0;
-}
-
-int
build_data(char *source, char *options, struct lustre_mount_data *lmd,
int *flagp)
{
- char buf[1024];
- char *hostname = NULL, *mds = NULL, *profile = NULL, *s;
- int rc;
+ char buf[1024];
+ char *nid = NULL;
+ char *mds = NULL;
+ char *profile = NULL;
+ char *s;
+ int rc;
if (lmd_bad_magic(lmd))
return -EINVAL;
if (strlen(source) >= sizeof(buf)) {
- fprintf(stderr, "%s: host:/mds/profile argument too long\n",
+ fprintf(stderr, "%s: nid:/mds/profile argument too long\n",
progname);
return -EINVAL;
}
strcpy(buf, source);
if ((s = strchr(buf, ':'))) {
- hostname = buf;
+ nid = buf;
*s = '\0';
while (*++s == '/')
}
} else {
fprintf(stderr, "%s: "
- "directory to mount not in host:/mds/profile format\n",
+ "directory to mount not in nid:/mds/profile format\n",
progname);
return(1);
}
if (rc)
return rc;
- rc = set_local(lmd);
- if (rc)
- return rc;
+ lmd->lmd_nid = libcfs_str2nid(nid);
+ if (lmd->lmd_nid == PTL_NID_ANY) {
+ fprintf(stderr, "%s: can't parse nid '%s'\n",
+ progname, libcfs_nid2str(lmd->lmd_nid));
+ return 1;
+ }
- rc = set_peer(hostname, lmd);
- if (rc)
- return rc;
if (strlen(mds) > sizeof(lmd->lmd_mds) + 1) {
fprintf(stderr, "%s: mds name too long\n", progname);
return(1);
return 0;
}
-static int set_routes(struct lustre_mount_data *lmd) {
- struct portals_cfg pcfg;
- struct portal_ioctl_data data;
- int i, j, route_exists, rc, err = 0;
-
- register_ioc_dev(PORTALS_DEV_ID, PORTALS_DEV_PATH);
-
- for (i = 0; i < route_index; i++) {
-
- /* Check for existing routes so as not to add duplicates */
- for (j = 0; ; j++) {
- PCFG_INIT(pcfg, NAL_CMD_GET_ROUTE);
- pcfg.pcfg_nal = ROUTER;
- pcfg.pcfg_count = j;
-
- PORTAL_IOC_INIT(data);
- data.ioc_pbuf1 = (char*)&pcfg;
- data.ioc_plen1 = sizeof(pcfg);
- data.ioc_nid = pcfg.pcfg_nid;
-
- rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data);
- if (rc != 0) {
- route_exists = 0;
- break;
- }
-
- if ((pcfg.pcfg_gw_nal == lmd->lmd_nal) &&
- (pcfg.pcfg_nid == routes[i].gw) &&
- (pcfg.pcfg_nid2 == routes[i].lo) &&
- (pcfg.pcfg_nid3 == routes[i].hi)) {
- route_exists = 1;
- break;
- }
- }
-
- if (route_exists)
- continue;
-
- PCFG_INIT(pcfg, NAL_CMD_ADD_ROUTE);
- pcfg.pcfg_nid = routes[i].gw;
- pcfg.pcfg_nal = ROUTER;
- pcfg.pcfg_gw_nal = lmd->lmd_nal;
- pcfg.pcfg_nid2 = MIN(routes[i].lo, routes[i].hi);
- pcfg.pcfg_nid3 = MAX(routes[i].lo, routes[i].hi);
-
- PORTAL_IOC_INIT(data);
- data.ioc_pbuf1 = (char*)&pcfg;
- data.ioc_plen1 = sizeof(pcfg);
- data.ioc_nid = pcfg.pcfg_nid;
-
- rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data);
- if (rc != 0) {
- fprintf(stderr, "%s: Unable to add route "
- LPX64" : "LPX64" - "LPX64"\n[%d] %s\n",
- progname, routes[i].gw, routes[i].lo,
- routes[i].hi, errno, strerror(errno));
- err = 2;
- break;
- }
- }
-
- unregister_ioc_dev(PORTALS_DEV_ID);
- return err;
-}
-
int main(int argc, char *const argv[])
{
char *source, *target, *options = "";
exit(1);
}
- if (!fake) {
- rc = set_routes(&lmd);
- if (rc)
- exit(2);
- }
-
rc = access(target, F_OK);
if (rc) {
rc = errno;
static
int do_add_uuid(char * func, char *uuid, ptl_nid_t nid)
{
- char tmp[64];
int rc;
struct lustre_cfg_bufs bufs;
struct lustre_cfg *lcfg;
return -1;
}
- printf ("Added uuid %s: %s\n", uuid, ptl_nid2str (tmp, nid));
+ printf ("Added uuid %s: %s\n", uuid, libcfs_nid2str(nid));
return 0;
}
int jt_lcfg_add_uuid(int argc, char **argv)
{
- ptl_nid_t nid = 0;
+ ptl_nid_t nid;
- if (argc != 4) {
+ if (argc != 3) {
return CMD_HELP;
}
- if (ptl_parse_nid (&nid, argv[2]) != 0) {
+ nid = libcfs_str2nid(argv[2]);
+ if (nid == PTL_NID_ANY) {
fprintf (stderr, "Can't parse NID %s\n", argv[2]);
- return (-1);
+ return (-1);
}
return do_add_uuid(argv[0], argv[1], nid);
int jt_obd_close_uuid(int argc, char **argv)
{
- int rc, nal;
+ int rc;
struct obd_ioctl_data data;
- if (argc != 3) {
- fprintf(stderr, "usage: %s <uuid> <net-type>\n", argv[0]);
+ if (argc != 2) {
+ fprintf(stderr, "usage: %s <uuid>\n", argv[0]);
return 0;
}
- nal = ptl_name2nal(argv[2]);
-
- if (nal <= 0) {
- fprintf (stderr, "Can't parse NAL %s\n", argv[2]);
- return -1;
- }
-
IOC_INIT(data);
data.ioc_inllen1 = strlen(argv[1]) + 1;
data.ioc_inlbuf1 = argv[1];
- data.ioc_nal = nal;
IOC_PACK(argv[0], data);
rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_CLOSE_UUID, buf);
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_RECORD, buf);
if (rc == 0) {
jt_recording = 1;
- ptl_set_cfg_record_cb(obd_record);
+ // ptl_set_cfg_record_cb(obd_record);
} else {
fprintf(stderr, "OBD_IOC_RECORD failed: %s\n",
strerror(errno));
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_ENDRECORD, buf);
if (rc == 0) {
jt_recording = 0;
- ptl_set_cfg_record_cb(NULL);
+ // ptl_set_cfg_record_cb(NULL);
} else {
fprintf(stderr, "OBD_IOC_ENDRECORD failed: %s\n",
strerror(errno));
CHECK_VALUE(MDS_UNLINK_REC);
CHECK_VALUE(MDS_SETATTR_REC);
CHECK_VALUE(OBD_CFG_REC);
- CHECK_VALUE(PTL_CFG_REC);
CHECK_VALUE(LLOG_GEN_REC);
CHECK_VALUE(LLOG_HDR_MAGIC);
CHECK_VALUE(LLOG_LOGID_MAGIC);
(long long)MDS_SETATTR_REC);
LASSERTF(OBD_CFG_REC == 274857984, " found %lld\n",
(long long)OBD_CFG_REC);
- LASSERTF(PTL_CFG_REC == 274923520, " found %lld\n",
- (long long)PTL_CFG_REC);
LASSERTF(LLOG_GEN_REC == 274989056, " found %lld\n",
(long long)LLOG_GEN_REC);
LASSERTF(LLOG_HDR_MAGIC == 275010873, " found %lld\n",