📄 obd_mount.c
字号:
GOTO(out, rc = -EBUSY); } /* The MGC has no recoverable data in any case. * force shotdown set in umount_begin */ obd->obd_no_recov = 1; if (obd->u.cli.cl_mgc_mgsexp) { /* An error is not fatal, if we are unable to send the disconnect mgs ping evictor cleans up the export */ rc = obd_disconnect(obd->u.cli.cl_mgc_mgsexp); if (rc) CDEBUG(D_MOUNT, "disconnect failed %d\n", rc); } /* Save the obdname for cleaning the nid uuids, which are obdname_XX */ len = strlen(obd->obd_name) + 6; OBD_ALLOC(niduuid, len); if (niduuid) { strcpy(niduuid, obd->obd_name); ptr = niduuid + strlen(niduuid); } rc = class_manual_cleanup(obd); if (rc) GOTO(out, rc); /* Clean the nid uuids */ if (!niduuid) GOTO(out, rc = -ENOMEM); for (i = 0; i < lsi->lsi_lmd->lmd_mgs_failnodes; i++) { sprintf(ptr, "_%x", i); rc = do_lcfg(LUSTRE_MGC_OBDNAME, 0, LCFG_DEL_UUID, niduuid, 0, 0, 0); if (rc) CERROR("del MDC UUID %s failed: rc = %d\n", niduuid, rc); }out: if (niduuid) OBD_FREE(niduuid, len); /* class_import_put will get rid of the additional connections */ mutex_up(&mgc_start_lock); RETURN(rc);}/* 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){ struct lustre_sb_info *lsi = s2lsi(sb); int rc; ENTRY; CDEBUG(D_MOUNT, "Set mgc disk for %s\n", lsi->lsi_lmd->lmd_dev); /* cl_mgc_sem in mgc insures we sleep if the mgc_fs is busy */ rc = obd_set_info_async(mgc->obd_self_export, strlen("set_fs"), "set_fs", sizeof(*sb), sb, NULL); if (rc) { CERROR("can't set_fs %d\n", rc); } RETURN(rc);}static int server_mgc_clear_fs(struct obd_device *mgc){ int rc; ENTRY; CDEBUG(D_MOUNT, "Unassign mgc disk\n"); rc = obd_set_info_async(mgc->obd_self_export, strlen("clear_fs"), "clear_fs", 0, NULL, NULL); RETURN(rc);}DECLARE_MUTEX(server_start_lock);/* Stop MDS/OSS if nobody is using them */static int server_stop_servers(int lddflags, int lsiflags){ struct obd_device *obd = NULL; struct obd_type *type = NULL; int rc = 0; ENTRY; mutex_down(&server_start_lock); /* Either an MDT or an OST or neither */ /* if this was an MDT, and there are no more MDT's, clean up the MDS */ if ((lddflags & LDD_F_SV_TYPE_MDT) && (obd = class_name2obd(LUSTRE_MDS_OBDNAME))) { /*FIXME pre-rename, should eventually be LUSTRE_MDT_NAME*/ type = class_search_type(LUSTRE_MDS_NAME); } /* if this was an OST, and there are no more OST's, clean up the OSS */ if ((lddflags & LDD_F_SV_TYPE_OST) && (obd = class_name2obd(LUSTRE_OSS_OBDNAME))) { type = class_search_type(LUSTRE_OST_NAME); } if (obd && (!type || !type->typ_refcnt)) { int err; obd->obd_force = 1; /* obd_fail doesn't mean much on a server obd */ err = class_manual_cleanup(obd); if (!rc) rc = err; } mutex_up(&server_start_lock); RETURN(rc);}int server_mti_print(char *title, struct mgs_target_info *mti){ PRINT_CMD(PRINT_MASK, "mti %s\n", title); PRINT_CMD(PRINT_MASK, "server: %s\n", mti->mti_svname); PRINT_CMD(PRINT_MASK, "fs: %s\n", mti->mti_fsname); PRINT_CMD(PRINT_MASK, "uuid: %s\n", mti->mti_uuid); PRINT_CMD(PRINT_MASK, "ver: %d flags: %#x\n", mti->mti_config_ver, mti->mti_flags); return(0);}static int server_sb2mti(struct super_block *sb, struct mgs_target_info *mti){ struct lustre_sb_info *lsi = s2lsi(sb); struct lustre_disk_data *ldd = lsi->lsi_ldd; lnet_process_id_t id; int i = 0; ENTRY; if (!(lsi->lsi_flags & LSI_SERVER)) RETURN(-EINVAL); strncpy(mti->mti_fsname, ldd->ldd_fsname, sizeof(mti->mti_fsname)); strncpy(mti->mti_svname, ldd->ldd_svname, sizeof(mti->mti_svname)); mti->mti_nid_count = 0; while (LNetGetId(i++, &id) != -ENOENT) { if (LNET_NETTYP(LNET_NIDNET(id.nid)) == LOLND) continue; mti->mti_nids[mti->mti_nid_count] = id.nid; mti->mti_nid_count++; if (mti->mti_nid_count >= MTI_NIDS_MAX) { CWARN("Only using first %d nids for %s\n", mti->mti_nid_count, mti->mti_svname); break; } } mti->mti_lustre_ver = LUSTRE_VERSION_CODE; mti->mti_config_ver = 0; mti->mti_flags = ldd->ldd_flags; mti->mti_stripe_index = ldd->ldd_svindex; memcpy(mti->mti_uuid, ldd->ldd_uuid, sizeof(mti->mti_uuid)); if (strlen(ldd->ldd_params) > sizeof(mti->mti_params)) { CERROR("params too big for mti\n"); RETURN(-ENOMEM); } memcpy(mti->mti_params, ldd->ldd_params, sizeof(mti->mti_params)); RETURN(0);}/* Register an old or new target with the MGS. If needed MGS will construct startup logs and assign index */int server_register_target(struct super_block *sb){ struct lustre_sb_info *lsi = s2lsi(sb); struct obd_device *mgc = lsi->lsi_mgc; struct lustre_disk_data *ldd = lsi->lsi_ldd; struct mgs_target_info *mti = NULL; int rc; ENTRY; LASSERT(mgc); if (!(lsi->lsi_flags & LSI_SERVER)) RETURN(-EINVAL); OBD_ALLOC_PTR(mti); if (!mti) RETURN(-ENOMEM); rc = server_sb2mti(sb, mti); if (rc) GOTO(out, rc); CDEBUG(D_MOUNT, "Registration %s, fs=%s, %s, index=%04x, flags=%#x\n", mti->mti_svname, mti->mti_fsname, libcfs_nid2str(mti->mti_nids[0]), mti->mti_stripe_index, mti->mti_flags); /* Register the target */ /* FIXME use mgc_process_config instead */ rc = obd_set_info_async(mgc->u.cli.cl_mgc_mgsexp, strlen("register_target"), "register_target", sizeof(*mti), mti, NULL); if (rc) GOTO(out, rc); /* Always update our flags */ ldd->ldd_flags = mti->mti_flags & ~LDD_F_REWRITE_LDD; /* If this flag is set, it means the MGS wants us to change our on-disk data. (So far this means just the index.) */ if (mti->mti_flags & LDD_F_REWRITE_LDD) { char *label; int err; CDEBUG(D_MOUNT, "Changing on-disk index from %#x to %#x " "for %s\n", ldd->ldd_svindex, mti->mti_stripe_index, mti->mti_svname); ldd->ldd_svindex = mti->mti_stripe_index; strncpy(ldd->ldd_svname, mti->mti_svname, sizeof(ldd->ldd_svname)); /* or ldd_make_sv_name(ldd); */ ldd_write(&mgc->obd_lvfs_ctxt, ldd); err = fsfilt_set_label(mgc, lsi->lsi_srv_mnt->mnt_sb, mti->mti_svname); if (err) CERROR("Label set error %d\n", err); label = fsfilt_get_label(mgc, lsi->lsi_srv_mnt->mnt_sb); if (label) CDEBUG(D_MOUNT, "Disk label changed to %s\n", label); /* Flush the new ldd to disk */ fsfilt_sync(mgc, lsi->lsi_srv_mnt->mnt_sb); }out: if (mti) OBD_FREE_PTR(mti); RETURN(rc);}/* Start targets */static int server_start_targets(struct super_block *sb, struct vfsmount *mnt){ struct obd_device *obd; struct lustre_sb_info *lsi = s2lsi(sb); struct config_llog_instance cfg; int rc; ENTRY; CDEBUG(D_MOUNT, "starting target %s\n", lsi->lsi_ldd->ldd_svname); /* If we're an MDT, make sure the global MDS is running */ if (lsi->lsi_ldd->ldd_flags & LDD_F_SV_TYPE_MDT) { /* make sure the MDS is started */ mutex_down(&server_start_lock); obd = class_name2obd(LUSTRE_MDS_OBDNAME); if (!obd) { rc = lustre_start_simple(LUSTRE_MDS_OBDNAME, /* FIXME pre-rename, should eventually be LUSTRE_MDS_NAME */ LUSTRE_MDT_NAME, LUSTRE_MDS_OBDNAME"_uuid", 0, 0); if (rc) { mutex_up(&server_start_lock); CERROR("failed to start MDS: %d\n", rc); RETURN(rc); } } mutex_up(&server_start_lock); } /* If we're an OST, make sure the global OSS is running */ if (lsi->lsi_ldd->ldd_flags & LDD_F_SV_TYPE_OST) { /* make sure OSS is started */ mutex_down(&server_start_lock); obd = class_name2obd(LUSTRE_OSS_OBDNAME); if (!obd) { rc = lustre_start_simple(LUSTRE_OSS_OBDNAME, LUSTRE_OSS_NAME, LUSTRE_OSS_OBDNAME"_uuid", 0, 0); if (rc) { mutex_up(&server_start_lock); CERROR("failed to start OSS: %d\n", rc); RETURN(rc); } } mutex_up(&server_start_lock); } /* Set the mgc fs to our server disk. This allows the MGC to read and write configs locally. */ rc = server_mgc_set_fs(lsi->lsi_mgc, sb); if (rc) RETURN(rc); /* Register with MGS */ rc = server_register_target(sb); if (rc && (lsi->lsi_ldd->ldd_flags & (LDD_F_NEED_INDEX | LDD_F_UPDATE | LDD_F_UPGRADE14))){ CERROR("Required registration failed for %s: %d\n", lsi->lsi_ldd->ldd_svname, rc); if (rc == -EIO) { LCONSOLE_ERROR_MSG(0x15f, "Communication error with the" " MGS. Is the MGS running?\n"); } GOTO(out_mgc, rc); } if (rc == -EINVAL) { LCONSOLE_ERROR_MSG(0x160, "The MGS is refusing to allow this " "server (%s) to start. Please see messages " "on the MGS node.\n", lsi->lsi_ldd->ldd_svname); GOTO(out_mgc, rc); } /* non-fatal error of registeration with MGS */ if (rc) CDEBUG(D_MOUNT, "Cannot register with MGS: %d\n", rc); /* Let the target look up the mount using the target's name (we can't pass the sb or mnt through class_process_config.) */ rc = server_register_mount(lsi->lsi_ldd->ldd_svname, sb, mnt); if (rc) GOTO(out_mgc, rc); /* Start targets using the llog named for the target */ memset(&cfg, 0, sizeof(cfg)); rc = lustre_process_log(sb, lsi->lsi_ldd->ldd_svname, &cfg); if (rc) { CERROR("failed to start server %s: %d\n", lsi->lsi_ldd->ldd_svname, rc); GOTO(out_mgc, rc); }out_mgc: /* Release the mgc fs for others to use */ server_mgc_clear_fs(lsi->lsi_mgc); if (!rc) { obd = class_name2obd(lsi->lsi_ldd->ldd_svname); if (!obd) { CERROR("no server named %s was started\n", lsi->lsi_ldd->ldd_svname); RETURN(-ENXIO); } if ((lsi->lsi_lmd->lmd_flags & LMD_FLG_ABORT_RECOV) && (OBP(obd, iocontrol))) { obd_iocontrol(OBD_IOC_ABORT_RECOVERY, obd->obd_self_export, 0, NULL, NULL); } /* log has been fully processed */ obd_notify(obd, NULL, OBD_NOTIFY_CONFIG, (void *)CONFIG_LOG); } RETURN(rc);}/***************** lustre superblock **************/struct lustre_sb_info *lustre_init_lsi(struct super_block *sb){ struct lustre_sb_info *lsi = NULL; ENTRY; OBD_ALLOC(lsi, sizeof(*lsi)); if (!lsi) RETURN(NULL); OBD_ALLOC(lsi->lsi_lmd, sizeof(*lsi->lsi_lmd)); if (!lsi->lsi_lmd) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -