Whamcloud - gitweb
b=20581 MDS returns full hash for readdir to decrease hash collision
[fs/lustre-release.git] / lustre / obdclass / obd_mount.c
index a8ff6c2..b270344 100644 (file)
@@ -273,7 +273,7 @@ static void ldd_print(struct lustre_disk_data *ldd)
 #endif
 
 static int ldd_parse(struct lvfs_run_ctxt *mount_ctxt,
-                           struct lustre_disk_data *ldd)
+                     struct lustre_disk_data *ldd)
 {
         struct lvfs_run_ctxt saved;
         struct file *file;
@@ -923,13 +923,13 @@ static int server_stop_servers(int lddflags, int lsiflags)
 
         /* 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 & SVTYPE_MDT) &&
+        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 & SVTYPE_OST) &&
+        if ((lddflags & LDD_F_SV_TYPE_OST) &&
             (obd = class_name2obd(LUSTRE_OSS_OBDNAME))) {
                 type = class_search_type(LUSTRE_OST_NAME);
         }
@@ -1095,7 +1095,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt)
 
 #if 0
         /* If we're an MDT, make sure the global MDS is running */
-        if (lsi->lsi_ldd->ldd_flags & SVTYPE_MDT) {
+        if (lsi->lsi_ldd->ldd_flags & LDD_F_SV_TYPE_MDT) {
                 /* make sure the MDS is started */
                 cfs_mutex_down(&server_start_lock);
                 obd = class_name2obd(LUSTRE_MDS_OBDNAME);
@@ -1116,7 +1116,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt)
 #endif
 
         /* If we're an OST, make sure the global OSS is running */
-        if (lsi->lsi_ldd->ldd_flags & SVTYPE_OST) {
+        if (lsi->lsi_ldd->ldd_flags & LDD_F_SV_TYPE_OST) {
                 /* make sure OSS is started */
                 cfs_mutex_down(&server_start_lock);
                 obd = class_name2obd(LUSTRE_OSS_OBDNAME);
@@ -1311,6 +1311,7 @@ static struct vfsmount *server_kernel_mount(struct super_block *sb)
         unsigned long page, s_flags;
         struct page *__page;
         int rc;
+        int len;
         ENTRY;
 
         OBD_ALLOC(ldd, sizeof(*ldd));
@@ -1363,11 +1364,18 @@ static struct vfsmount *server_kernel_mount(struct super_block *sb)
 
         /* Glom up mount options */
         memset(options, 0, CFS_PAGE_SIZE);
-        strncpy(options, ldd->ldd_mount_opts, CFS_PAGE_SIZE - 2);
+        if (IS_MDT(ldd)) {
+                /* enable 64bithash for MDS by force */
+                strcpy(options, "64bithash,");
+                len = CFS_PAGE_SIZE - strlen(options) - 2;
+                strncat(options, ldd->ldd_mount_opts, len);
+        } else {
+                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;
+                len = CFS_PAGE_SIZE - strlen(options) - 2;
                 if (*options != 0)
                         strcat(options, ",");
                 strncat(options, lmd->lmd_opts, len);
@@ -1729,6 +1737,41 @@ out_mnt:
         return rc;
 }
 
+/* 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 = strrchr(svname, '-');
+        if (!dash)
+                return(-EINVAL);
+
+        /* intepret <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--);
+                if (dash == svname)
+                        return(-EINVAL);
+        }
+
+        if (strncmp(dash + 1, "MDT", 3) == 0)
+                rc = LDD_F_SV_TYPE_MDT;
+        else if (strncmp(dash + 1, "OST", 3) == 0)
+                rc = LDD_F_SV_TYPE_OST;
+        else
+                return(-EINVAL);
+        if (strcmp(dash + 4, "all") == 0)
+                return rc | LDD_F_SV_ALL;
+
+        index = simple_strtoul(dash + 4, endptr, 16);
+        *idx = index;
+        return rc;
+}
+
 /*************** mount common betweeen server and client ***************/
 
 /* Common umount */
@@ -1792,8 +1835,8 @@ int lustre_check_exclusion(struct super_block *sb, char *svname)
         int i, rc;
         ENTRY;
 
-        rc = libcfs_str2server(svname, &i, &index, NULL);
-        if (rc ||  i != SVTYPE_OST)
+        rc = server_name2index(svname, &index, NULL);
+        if (rc != LDD_F_SV_TYPE_OST)
                 /* Only exclude OSTs */
                 RETURN(0);
 
@@ -1814,7 +1857,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, char *ptr)
 {
         char *s1 = ptr, *s2;
         __u32 index, *exclude_list;
-        int rc = 0, devmax, type;
+        int rc = 0, devmax;
         ENTRY;
 
         /* The shortest an ost name can be is 8 chars: -OST0000.
@@ -1830,12 +1873,12 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, char *ptr)
         /* we enter this fn pointing at the '=' */
         while (*s1 && *s1 != ' ' && *s1 != ',') {
                 s1++;
-                rc = libcfs_str2server(s1, &type, &index, &s2);
+                rc = server_name2index(s1, &index, &s2);
                 if (rc < 0) {
                         CERROR("Can't parse server name '%s'\n", s1);
                         break;
                 }
-                if (type == SVTYPE_OST)
+                if (rc == LDD_F_SV_TYPE_OST)
                         exclude_list[lmd->lmd_exclude_count++] = index;
                 else
                         CDEBUG(D_MOUNT, "ignoring exclude %.7s\n", s1);
@@ -2186,5 +2229,6 @@ EXPORT_SYMBOL(server_get_mount_2);
 EXPORT_SYMBOL(server_put_mount);
 EXPORT_SYMBOL(server_put_mount_2);
 EXPORT_SYMBOL(server_register_target);
+EXPORT_SYMBOL(server_name2index);
 EXPORT_SYMBOL(server_mti_print);
 EXPORT_SYMBOL(do_lcfg);