Whamcloud - gitweb
b=20187
authoralex <alex>
Thu, 5 Nov 2009 11:17:44 +0000 (11:17 +0000)
committeralex <alex>
Thu, 5 Nov 2009 11:17:44 +0000 (11:17 +0000)
 - return to HEAD-compatible configuration protocol
 - mountconf to convert on-disk label locally and prepare HEAD-like mti structure
 - mkfs.lustre to set a special label (not from make_server_name()) on a fresh device

lustre/include/lustre_disk.h
lustre/mgs/mgs_handler.c
lustre/mgs/mgs_llog.c
lustre/obdclass/obd_mount.c
lustre/utils/mkfs_lustre.c

index 802013e..a085187 100644 (file)
@@ -144,16 +144,10 @@ static inline int server_make_name(__u32 flags, __u16 index, char *fs,
                                    char *name)
 {
         if (flags & (LDD_F_SV_TYPE_MDT | LDD_F_SV_TYPE_OST)) {
-                if (!(flags & LDD_F_SV_ALL)) {
-                        sprintf(name, "%.8s%c%s", fs,
-                                (flags & LDD_F_VIRGIN) ? ':' : '-',
-                                (flags & LDD_F_SV_TYPE_MDT) ? "MDT" : "OST");
-
-                        if (flags & LDD_F_NEED_INDEX)
-                                sprintf(&name[strlen(name)], "u%03x", index);
-                        else
-                                sprintf(&name[strlen(name)], "%04x", index);
-                }
+                if (!(flags & LDD_F_SV_ALL))
+                        sprintf(name, "%.8s-%s%04x", fs,
+                                (flags & LDD_F_SV_TYPE_MDT) ? "MDT" : "OST",
+                                index);
         } else if (flags & LDD_F_SV_TYPE_MGS) {
                 sprintf(name, "MGS");
         } else {
index c6bf24b..bd4b8f4 100644 (file)
@@ -60,6 +60,7 @@
 #include <lustre_disk.h>
 #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,
@@ -395,36 +396,6 @@ 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 rc;
-        ENTRY;
-
-        if (mti->mti_fsname[0] != '\0') {
-                /* empty fsname expected with "label-only" registration */
-                GOTO(out, rc = -EINVAL);
-        }
-
-        rc = server_name2fsname(mti->mti_svname, mti->mti_fsname, NULL);
-        if (rc != 0)
-                goto out;
-
-        rc = server_name2index(mti->mti_svname, &mti->mti_stripe_index, NULL);
-        if (rc < 0)
-                goto out;
-
-        mti->mti_flags = rc;
-        if (mti->mti_flags & LDD_F_VIRGIN)
-                mti->mti_flags |= LDD_F_UPDATE;
-
-        CDEBUG(D_MGS, "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)
 {
@@ -437,14 +408,6 @@ 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. */
index cad1596..5b770b2 100644 (file)
@@ -557,7 +557,6 @@ int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti)
                 if (rc == -1)
                         RETURN(-ERANGE);
                 mti->mti_stripe_index = rc;
-                mti->mti_flags &= ~LDD_F_NEED_INDEX;
         }
 
         if (mti->mti_stripe_index >= INDEX_MAP_SIZE * 8) {
@@ -2683,11 +2682,6 @@ int mgs_write_log_target(struct obd_device *obd,
 
         if (mti->mti_flags &
             (LDD_F_VIRGIN | LDD_F_UPGRADE14 | LDD_F_WRITECONF)) {
-                /* Update target name from fsname:XXXyyyy -> fsname-XXXyyyy */
-                mti->mti_flags &= ~LDD_F_VIRGIN;
-                server_make_name(mti->mti_flags, mti->mti_stripe_index,
-                                 mti->mti_fsname, mti->mti_svname);
-
                 /* Generate a log from scratch */
                 if (mti->mti_flags & LDD_F_SV_TYPE_MDT) {
                         rc = mgs_write_log_mdt(obd, fsdb, mti);
index e7dca7a..2c16c77 100644 (file)
@@ -904,11 +904,118 @@ int server_mti_print(char *title, struct mgs_target_info *mti)
         return(0);
 }
 
+/* Get the fsname from the obd name.
+   fsname must have at least 'strlen(svname) + 1' chars.
+   rc < 0  on error
+   if endptr isn't NULL it is set to end of fsname */
+int server_name2fsname(char *svname, char *fsname, char **endptr)
+{
+        char *dash = strrchr(svname, '-');
+        if (!dash) {
+                dash = strrchr(svname, ':');
+                if (!dash)
+                        return -EINVAL;
+        }
+
+        /* interpret <fsname>-MDTXXXXX-mdc as mdt, the better way is to pass
+         * in the fsname, then determine the server index */
+        if (!strcmp(LUSTRE_MDC_NAME, dash + 1)) {
+                dash--;
+                for (; dash > svname && *dash != '-' && *dash != ':'; dash--);
+                if (dash == svname)
+                        return -EINVAL;
+        }
+
+        if (fsname != NULL) {
+                strncpy(fsname, svname, dash - svname);
+                fsname[dash - svname] = '\0';
+        }
+
+        if (endptr != NULL)
+                *endptr = dash;
+
+        return 0;
+}
+
+/**
+ * Get service name (svname) from string
+ * rc < 0 on error
+ * if endptr isn't NULL it is set to end of fsname *
+ */
+
+int server_name2svname(char *label, char *svname, char **endptr)
+{
+        int rc;
+        char *dash;
+
+        /* We use server_name2fsname() just for parsing */
+        rc = server_name2fsname(label, NULL, &dash);
+        if (rc != 0)
+                return rc;
+        
+        if (*dash == ':')
+                strncpy(svname, dash + 1, MTI_NAME_MAXLEN);
+        else
+                strncpy(svname, label, MTI_NAME_MAXLEN);
+        
+        return 0;
+}
+
+
+/* Get the index from the obd name.
+   rc = server type, or
+   rc < 0  on error
+   if endptr isn't NULL it is set to end of name */
+int server_name2index(char *svname, __u32 *idx, char **endptr)
+{
+        unsigned long index;
+        int rc;
+        char *dash;
+
+        /* We use server_name2fsname() just for parsing */
+        rc = server_name2fsname(svname, NULL, &dash);
+        if (rc != 0)
+                return rc;
+
+        if (*dash == ':')
+                rc |= LDD_F_VIRGIN;
+
+        dash++;
+
+        if (strncmp(dash, "MDT", 3) == 0)
+                rc |= LDD_F_SV_TYPE_MDT;
+        else if (strncmp(dash, "OST", 3) == 0)
+                rc |= LDD_F_SV_TYPE_OST;
+        else
+                return(-EINVAL);
+
+        dash += 3;
+
+        if (strcmp(dash, "all") == 0)
+                return rc | LDD_F_SV_ALL;
+
+        if (strcmp(dash, "ffff") == 0) {
+                rc |= LDD_F_NEED_INDEX;
+                *idx = 65535;
+                return rc;
+        }
+
+        if (*dash == 'u') {
+                rc |= LDD_F_NEED_INDEX;
+                dash++;
+        }
+
+        index = simple_strtoul(dash, endptr, 16);
+        *idx = index;
+        return rc;
+}
+
 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);
-        char *label;
+        struct lustre_sb_info  *lsi = s2lsi(sb);
+        struct dt_device_param  dt_param;
+        char                   *label;
+        int                     rc;
 
         LASSERT(lsi);
         LASSERT(lsi->lsi_dt_dev);
@@ -921,9 +1028,21 @@ 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;
 
-        mti->mti_flags = 0;
-        strncpy(mti->mti_svname, label, sizeof(mti->mti_svname));
-        mti->mti_svname[sizeof(mti->mti_svname) - 1] = '\0';
+        rc = server_name2fsname(label, mti->mti_fsname, NULL);
+        if (rc != 0)
+                return rc;
+
+        rc = server_name2svname(label, mti->mti_svname, NULL);
+        if (rc != 0)
+                return rc;
+
+        rc = server_name2index(label, &mti->mti_stripe_index, NULL);
+        if (rc < 0)
+                return rc;
+
+        mti->mti_flags = rc;
+        if (mti->mti_flags & LDD_F_VIRGIN)
+                mti->mti_flags |= LDD_F_UPDATE;
 
         return 0;
 }
@@ -1989,81 +2108,6 @@ out_mnt:
         return rc;
 }
 
-/* Get the fsname from the obd name.
-   fsname must have at least 'strlen(svname) + 1' chars.
-   rc < 0  on error
-   if endptr isn't NULL it is set to end of fsname */
-int server_name2fsname(char *svname, char *fsname, char **endptr)
-{
-        char *dash = strrchr(svname, '-');
-        if (!dash) {
-                dash = strrchr(svname, ':');
-                if (!dash)
-                        return -EINVAL;
-        }
-
-        /* interpret <fsname>-MDTXXXXX-mdc as mdt, the better way is to pass
-         * in the fsname, then determine the server index */
-        if (!strcmp(LUSTRE_MDC_NAME, dash + 1)) {
-                dash--;
-                for (; dash > svname && *dash != '-' && *dash != ':'; dash--);
-                if (dash == svname)
-                        return -EINVAL;
-        }
-
-        if (fsname != NULL) {
-                strncpy(fsname, svname, dash - svname);
-                fsname[dash - svname] = '\0';
-        }
-
-        if (endptr != NULL)
-                *endptr = dash;
-
-        return 0;
-}
-
-/* Get the index from the obd name.
-   rc = server type, or
-   rc < 0  on error
-   if endptr isn't NULL it is set to end of name */
-int server_name2index(char *svname, __u32 *idx, char **endptr)
-{
-        unsigned long index;
-        int rc;
-        char *dash;
-
-        /* We use server_name2fsname() just for parsing */
-        rc = server_name2fsname(svname, NULL, &dash);
-        if (rc != 0)
-                return rc;
-
-        if (*dash == ':')
-                rc |= LDD_F_VIRGIN;
-
-        dash++;
-
-        if (strncmp(dash, "MDT", 3) == 0)
-                rc |= LDD_F_SV_TYPE_MDT;
-        else if (strncmp(dash, "OST", 3) == 0)
-                rc |= LDD_F_SV_TYPE_OST;
-        else
-                return(-EINVAL);
-
-        dash += 3;
-
-        if (strcmp(dash, "all") == 0)
-                return rc | LDD_F_SV_ALL;
-
-        if (*dash == 'u') {
-                rc |= LDD_F_NEED_INDEX;
-                dash++;
-        }
-
-        index = simple_strtoul(dash, endptr, 16);
-        *idx = index;
-        return rc;
-}
-
 /*************** mount common betweeen server and client ***************/
 
 /* Common umount */
index 9389ce5..c8749e7 100644 (file)
@@ -765,7 +765,10 @@ int make_lustre_backfs(struct mkfs_opts *mop)
 
                 /* Set the label */
                 snprintf(mkfs_cmd, sizeof(mkfs_cmd), "zfs set "
-                         "com.sun.lustre:label=%s %s", mop->mo_ldd.ldd_svname,
+                         "com.sun.lustre:label=%s:%s%04x %s",
+                         mop->mo_ldd.ldd_fsname,
+                         mop->mo_ldd.ldd_flags & LDD_F_SV_TYPE_MDT ? "MDT":"OST",
+                         mop->mo_ldd.ldd_svindex,
                          mop->mo_device);
                 mkfs_cmd[sizeof(mkfs_cmd) - 1] = '\0';