From: alex Date: Tue, 3 Mar 2009 08:30:40 +0000 (+0000) Subject: - MGS does label parsing in case of absent mountdata X-Git-Tag: GIT_EPOCH_B_HD_KDMU~2^4~134 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=906ebcbf4091683a6fc8ccc4b00448b63b40ea48;p=fs%2Flustre-release.git - MGS does label parsing in case of absent mountdata - no need to pass fsname as mountoption - mke2fs -L lustre*OSTXXXX, then mount -t lustre -o mgs= is enough to get new OST --- diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index b8fc609..34dfc67 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -180,7 +180,6 @@ struct lustre_mount_data { _device_ mount options) */ __u32 *lmd_exclude; /* array of OSTs to ignore */ char *lmd_mgs; /* MGS nid */ - char *lmd_fsname; /* fs name for first mount */ }; #define LMD_FLG_SERVER 0x0001 /* Mounting a server */ diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 3efcfae..dbd2c45 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -60,7 +60,6 @@ #include #include "mgs_internal.h" - /* Establish a connection to the MGS.*/ static int mgs_connect(const struct lu_env *env, struct obd_export **exp, struct obd_device *obd, @@ -418,6 +417,74 @@ static int mgs_check_target(struct obd_device *obd, struct mgs_target_info *mti) RETURN(rc); } +static int mgs_parse_label_to_mti(struct mgs_target_info *mti) +{ + int i = 0, rc = 0; + ENTRY; + + /* + * Format: + * registered target: - + * unregistered target: * + */ + + if (mti->mti_fsname[0] != '\0') { + /* empty fsname expected with "label-only" registration */ + GOTO(out, rc = -EINVAL); + } + + while (i < MTI_NAME_MAXLEN) { + if (mti->mti_svname[i] == 0) { + /* no delimiter found */ + GOTO(out, rc = -EINVAL); + } + if (mti->mti_svname[i] == '*') { + mti->mti_flags |= LDD_F_VIRGIN | LDD_F_UPDATE; + break; + } + if (mti->mti_svname[i] == '-') { + break; + } + mti->mti_fsname[i] = mti->mti_svname[i]; + i++; + } + mti->mti_fsname[i] = '\0'; + i++; + + if (i >= MTI_NAME_MAXLEN - 7) + GOTO(out, rc = -EINVAL); + + if (!strncmp(mti->mti_svname + i, "OST", 3)) { + mti->mti_flags |= LDD_F_SV_TYPE_OST; + } else if (!strncmp(mti->mti_svname + i, "MDT", 3)) { + mti->mti_flags |= LDD_F_SV_TYPE_MDT; + } else { + /* unknown node type */ + CERROR("unknown type %s\n", mti->mti_svname + i); + GOTO(out, rc = -EINVAL); + } + i += 3; + + if (!strcmp(mti->mti_svname + i, "XXXX")) { + if (!(mti->mti_flags & LDD_F_VIRGIN)) { + /* expected to be new */ + GOTO(out, rc = -EINVAL); + } + + mti->mti_flags |= LDD_F_NEED_INDEX; + mti->mti_svname[0] = '\0'; + } else { + mti->mti_stripe_index = simple_strtoul(mti->mti_svname+i,NULL,10); + } + + CDEBUG(D_MOUNT, "register to %s with name '%s' and flags %u\n", + mti->mti_fsname, mti->mti_svname, mti->mti_flags); + +out: + RETURN(rc); +} + + /* Called whenever a target starts up. Flags indicate first connect, etc. */ static int mgs_handle_target_reg(struct ptlrpc_request *req) { @@ -430,6 +497,14 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) mgs_counter_incr(req->rq_export, LPROC_MGS_TARGET_REG); mti = req_capsule_client_get(&req->rq_pill, &RMF_MGS_TARGET_INFO); + + /* if no other data is supplied, parse label */ + if (mti->mti_flags == 0) { + rc = mgs_parse_label_to_mti(mti); + if (rc < 0) + GOTO(out_nolock, rc); + } + if (!(mti->mti_flags & (LDD_F_WRITECONF | LDD_F_UPGRADE14 | LDD_F_UPDATE))) { /* We're just here as a startup ping. */ diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 4b8921d..84e41f6 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -906,7 +906,6 @@ static int server_label2mti(struct super_block *sb, struct mgs_target_info *mti) { struct dt_device_param dt_param; struct lustre_sb_info *lsi = s2lsi(sb); - unsigned newsv_flags; char *label; LASSERT(lsi); @@ -918,29 +917,9 @@ static int server_label2mti(struct super_block *sb, struct mgs_target_info *mti) lsi->lsi_dt_dev->dd_ops->dt_conf_get(NULL, lsi->lsi_dt_dev, &dt_param); lsi->lsi_ldd->ldd_mount_type = dt_param.ddp_mount_type; - /* parse label: NEW:OST */ - newsv_flags = LDD_F_VIRGIN | LDD_F_UPDATE | LDD_F_NEED_INDEX; - if (!strcmp(label, "NEW:OST")) { - mti->mti_flags |= newsv_flags | LDD_F_SV_TYPE_OST; - } else if (!strcmp(label, "NEW:MDS")) { - mti->mti_flags |= newsv_flags | LDD_F_SV_TYPE_MDT; - } else if (strstr(label, "OST")) { - /* registered before service */ - mti->mti_flags |= LDD_F_SV_TYPE_OST; - strcpy(mti->mti_svname, label); - strcpy(lsi->lsi_ldd->ldd_svname, label); - } else if (strstr(label, "MDT")) { - /* registered before service */ - mti->mti_flags |= LDD_F_SV_TYPE_MDT; - strcpy(mti->mti_svname, label); - strcpy(lsi->lsi_ldd->ldd_svname, label); - } else { - LBUG(); - } - - if (lsi->lsi_lmd->lmd_fsname) - strncpy(mti->mti_fsname, lsi->lsi_lmd->lmd_fsname, - sizeof(mti->mti_fsname)); + mti->mti_flags = 0; + strncpy(mti->mti_svname, label, sizeof(mti->mti_svname)); + mti->mti_svname[sizeof(mti->mti_svname) - 1] = '\0'; return 0; } @@ -1058,6 +1037,12 @@ int server_register_target(struct super_block *sb) if (rc) GOTO(out, rc); + /* we don't have persistent ldd probably, + * but MGS * supplies us withservice name */ + ldd->ldd_svindex = mti->mti_stripe_index; + strncpy(ldd->ldd_svname, mti->mti_svname, + sizeof(ldd->ldd_svname)); + /* Always update our flags */ ldd->ldd_flags = mti->mti_flags & ~LDD_F_REWRITE_LDD; @@ -1069,9 +1054,6 @@ int server_register_target(struct super_block *sb) 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(lsi->lsi_dt_dev, ldd); err = mconf_set_label(lsi->lsi_dt_dev, mti->mti_svname); @@ -1310,9 +1292,6 @@ static int lustre_free_lsi(struct super_block *sb) if (lsi->lsi_lmd->lmd_mgs) OBD_FREE(lsi->lsi_lmd->lmd_mgs, strlen(lsi->lsi_lmd->lmd_mgs) + 1); - if (lsi->lsi_lmd->lmd_fsname) - OBD_FREE(lsi->lsi_lmd->lmd_fsname, - strlen(lsi->lsi_lmd->lmd_fsname) + 1); OBD_FREE(lsi->lsi_lmd, sizeof(*lsi->lsi_lmd)); } @@ -1568,16 +1547,11 @@ out: /* Kernel mount using mount options in MOUNT_DATA_FILE */ static struct dt_device *server_kernel_mount(struct super_block *sb) { - struct lvfs_run_ctxt mount_ctxt; struct lustre_sb_info *lsi = s2lsi(sb); struct lustre_disk_data *ldd; struct lustre_mount_data *lmd = lsi->lsi_lmd; struct lu_device *dev; struct mconf_device *mdev; - struct vfsmount *mnt; - char *options = NULL; - unsigned long page, s_flags; - struct page *__page; struct lu_site *site; int rc; @@ -1624,92 +1598,6 @@ static struct dt_device *server_kernel_mount(struct super_block *sb) } RETURN(lu2dt_dev(dev)); - - /* In the past, we have always used flags = 0. - Note ext3/ldiskfs can't be mounted ro. */ - s_flags = sb->s_flags; - - /* allocate memory for options */ - OBD_PAGE_ALLOC(__page, CFS_ALLOC_STD); - if (!__page) - GOTO(out_free, rc = -ENOMEM); - page = (unsigned long)cfs_page_address(__page); - options = (char *)page; - memset(options, 0, CFS_PAGE_SIZE); - - /* mount-line options must be added for pre-mount because it may - * contain mount options such as journal_dev which are required - * to mount successfuly the underlying filesystem */ - if (lmd->lmd_opts && (*(lmd->lmd_opts) != 0)) - strncat(options, lmd->lmd_opts, CFS_PAGE_SIZE - 1); - - /* Pre-mount ldiskfs to read the MOUNT_DATA_FILE */ - CDEBUG(D_MOUNT, "Pre-mount ldiskfs %s\n", lmd->lmd_dev); - mnt = ll_kern_mount("ldiskfs", s_flags, lmd->lmd_dev, (void *)options); - if (IS_ERR(mnt)) { - rc = PTR_ERR(mnt); - CERROR("premount %s:%#lx ldiskfs failed: %d " - "Is the ldiskfs module available?\n", - lmd->lmd_dev, s_flags, rc ); - GOTO(out_free, rc); - } - - OBD_SET_CTXT_MAGIC(&mount_ctxt); - mount_ctxt.pwdmnt = mnt; - mount_ctxt.pwd = mnt->mnt_root; - mount_ctxt.fs = get_ds(); - - //rc = ldd_parse(&mount_ctxt, ldd); - unlock_mntput(mnt); - - if (rc) { - CERROR("premount parse options failed: rc = %d\n", rc); - GOTO(out_free, rc); - } - - /* Done with our pre-mount, now do the real mount. */ - - /* Glom up mount options */ - memset(options, 0, CFS_PAGE_SIZE); - strncpy(options, ldd->ldd_mount_opts, CFS_PAGE_SIZE - 2); - - /* Add in any mount-line options */ - if (lmd->lmd_opts && (*(lmd->lmd_opts) != 0)) { - int len = CFS_PAGE_SIZE - strlen(options) - 2; - if (*options != 0) - strcat(options, ","); - strncat(options, lmd->lmd_opts, len); - } - - /* Special permanent mount flags */ - if (IS_OST(ldd)) - s_flags |= MS_NOATIME | MS_NODIRATIME; - - CDEBUG(D_MOUNT, "kern_mount: %s %s %s\n", - MT_STR(ldd), lmd->lmd_dev, options); - mnt = ll_kern_mount(MT_STR(ldd), s_flags, lmd->lmd_dev, - (void *)options); - if (IS_ERR(mnt)) { - rc = PTR_ERR(mnt); - CERROR("ll_kern_mount failed: rc = %d\n", rc); - GOTO(out_free, rc); - } - - if (lmd->lmd_flags & LMD_FLG_ABORT_RECOV) - simple_truncate(mnt->mnt_sb->s_root, mnt, LAST_RCVD, - LR_CLIENT_START); - - OBD_PAGE_FREE(__page); - lsi->lsi_ldd = ldd; /* freed at lsi cleanup */ - CDEBUG(D_SUPER, "%s: mnt = %p\n", lmd->lmd_dev, mnt); - RETURN(NULL); - -out_free: - if (__page) - OBD_PAGE_FREE(__page); - OBD_FREE(ldd, sizeof(*ldd)); - lsi->lsi_ldd = NULL; - RETURN(ERR_PTR(rc)); } static void server_wait_finished(struct vfsmount *mnt) @@ -1741,7 +1629,6 @@ static void server_put_super(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); struct obd_device *obd; - //struct vfsmount *mnt = lsi->lsi_srv_mnt; struct vfsmount *mnt = NULL; /* XXX: */ char *tmpname, *extraname = NULL; int tmpname_sz; @@ -1862,7 +1749,6 @@ static int server_statfs (struct dentry *dentry, struct kstatfs *buf) { struct super_block *sb = dentry->d_sb; #endif - //struct vfsmount *mnt = s2lsi(sb)->lsi_srv_mnt; struct vfsmount *mnt = NULL; ENTRY; @@ -2233,31 +2119,6 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char *ptr) return 0; } -static int lmd_parse_fsname(struct lustre_mount_data *lmd, char *ptr) -{ - char *tail; - int length; - - if (lmd->lmd_fsname != NULL) { - OBD_FREE(lmd->lmd_fsname, strlen(lmd->lmd_fsname) + 1); - lmd->lmd_fsname = NULL; - } - - tail = strchr(ptr, ','); - if (tail == NULL) - length = strlen(ptr); - else - length = tail - ptr; - - OBD_ALLOC(lmd->lmd_fsname, length + 1); - if (lmd->lmd_fsname == NULL) - return -ENOMEM; - - memcpy(lmd->lmd_fsname, ptr, length); - lmd->lmd_fsname[length] = '\0'; - return 0; -} - /* mount -v -t lustre uml1:uml2:/lustre-client /mnt/lustre */ static int lmd_parse(char *options, struct lustre_mount_data *lmd) { @@ -2321,11 +2182,6 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) if (rc) goto invalid; clear++; - } else if (strncmp(s1, "fsname=", 7) == 0) { - rc = lmd_parse_fsname(lmd, s1 + 7); - if (rc) - goto invalid; - clear++; } /* Linux 2.4 doesn't pass the device, so we stuck it at the end of the options. */