+static int lsi_prepare(struct lustre_sb_info *lsi)
+{
+ struct lustre_disk_data *ldd;
+ __u32 index;
+ int rc;
+ ENTRY;
+
+ LASSERT(lsi);
+ LASSERT(lsi->lsi_lmd);
+
+ OBD_ALLOC(ldd, sizeof(*ldd));
+ if (ldd == NULL)
+ RETURN(-ENOMEM);
+ strcpy(lsi->lsi_osd_type, LUSTRE_OSD_NAME);
+
+ /* The server name is given as a mount line option */
+ if (lsi->lsi_lmd->lmd_profile == NULL) {
+ LCONSOLE_ERROR("Can't determine server name\n");
+ RETURN(-EINVAL);
+ }
+
+ if (strlen(lsi->lsi_lmd->lmd_profile) >= sizeof(ldd->ldd_svname))
+ RETURN(-ENAMETOOLONG);
+
+ strcpy(ldd->ldd_svname, lsi->lsi_lmd->lmd_profile);
+ strcpy(ldd->ldd_fsname, "lustre");
+
+ /* Determine osd type */
+ if (lsi->lsi_lmd->lmd_osd_type != NULL) {
+ if (strlen(lsi->lsi_lmd->lmd_osd_type) >=
+ sizeof(lsi->lsi_osd_type))
+ RETURN (-ENAMETOOLONG);
+
+ strcpy(lsi->lsi_osd_type, lsi->lsi_lmd->lmd_osd_type);
+ }
+
+ /* Determine server type */
+ rc = server_name2index(ldd->ldd_svname, &index, NULL);
+ if (rc < 0) {
+ if (0 /*lsi->lsi_lmd->lmd_flags & LMD_FLG_MGS*/) {
+ /* Assume we're a bare MGS */
+ rc = 0;
+ lsi->lsi_lmd->lmd_flags |= LMD_FLG_NOSVC;
+ } else {
+ LCONSOLE_ERROR("Can't determine server type of '%s'\n",
+ lsi->lsi_svname);
+ RETURN(rc);
+ }
+ }
+ ldd->ldd_svindex = index;
+ //lsi->lsi_flags |= rc;
+ ldd->ldd_flags = rc | LDD_F_WRITECONF;
+
+ lsi->lsi_ldd = ldd;
+
+ /* Add mount line flags that used to be in ldd:
+ * writeconf, mgs, iam, anything else?
+ */
+#if 0
+ lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_WRITECONF) ?
+ LDD_F_WRITECONF : 0;
+ lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_MGS) ?
+ LDD_F_SV_TYPE_MGS : 0;
+ lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_IAM) ?
+ LDD_F_IAM_DIR : 0;
+ lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_NO_PRIMNODE) ?
+ LDD_F_NO_PRIMNODE : 0;
+#endif
+
+ RETURN(0);
+}
+