Whamcloud - gitweb
LU-13356 client: don't use OBD_CONNECT_MNE_SWAB
[fs/lustre-release.git] / lustre / obdclass / obd_mount.c
index 538efea..de23440 100644 (file)
@@ -50,6 +50,8 @@
 #include <lustre_disk.h>
 #include <uapi/linux/lustre/lustre_param.h>
 
+static DEFINE_SPINLOCK(client_lock);
+static struct module *client_mod;
 static int (*client_fill_super)(struct super_block *sb);
 
 static void (*kill_super_cb)(struct super_block *sb);
@@ -467,10 +469,6 @@ int lustre_start_mgc(struct super_block *sb)
                                  OBD_CONNECT_LVB_TYPE |
                                  OBD_CONNECT_BULK_MBITS | OBD_CONNECT_BARRIER;
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
-       data->ocd_connect_flags |= OBD_CONNECT_MNE_SWAB;
-#endif
-
        if (lmd_is_client(lsi->lsi_lmd) &&
            lsi->lsi_lmd->lmd_flags & LMD_FLG_NOIR)
                data->ocd_connect_flags &= ~OBD_CONNECT_IMP_RECOV;
@@ -1263,7 +1261,7 @@ try_again:
  */
 static int lmd_parse_nidlist(char *buf, char **endh)
 {
-       struct list_head nidlist;
+       LIST_HEAD(nidlist);
        char *endp = buf;
        char tmp;
        int rc = 0;
@@ -1281,7 +1279,6 @@ static int lmd_parse_nidlist(char *buf, char **endh)
        tmp = *endp;
        *endp = '\0';
 
-       INIT_LIST_HEAD(&nidlist);
        if (cfs_parse_nidlist(buf, strlen(buf), &nidlist) <= 0)
                rc = 1;
        cfs_free_nidlist(&nidlist);
@@ -1453,6 +1450,9 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
                        strlcat(lmd->lmd_params, " ", LMD_PARAMS_MAXLEN);
                        s3 = s1 + 6 + length;
                        clear++;
+               } else if (strncmp(s1, "localrecov", 10) == 0) {
+                       lmd->lmd_flags |= LMD_FLG_LOCAL_RECOV;
+                       clear++;
                } else if (strncmp(s1, "osd=", 4) == 0) {
                        rc = lmd_parse_string(&lmd->lmd_osd_type, s1 + 4);
                        if (rc)
@@ -1623,10 +1623,16 @@ static int lustre_fill_super(struct super_block *sb, void *lmd2_data,
        }
 
        if (lmd_is_client(lmd)) {
+               bool have_client = false;
+
                CDEBUG(D_MOUNT, "Mounting client %s\n", lmd->lmd_profile);
-               if (client_fill_super == NULL)
+               if (!client_fill_super)
                        request_module("lustre");
-               if (client_fill_super == NULL) {
+               spin_lock(&client_lock);
+               if (client_fill_super && try_module_get(client_mod))
+                       have_client = true;
+               spin_unlock(&client_lock);
+               if (!have_client) {
                        LCONSOLE_ERROR_MSG(0x165,
                                           "Nothing registered for client mount! Is the 'lustre' module loaded?\n");
                        lustre_put_lsi(sb);
@@ -1640,7 +1646,9 @@ static int lustre_fill_super(struct super_block *sb, void *lmd2_data,
                        /* Connect and start */
                        /* (should always be ll_fill_super) */
                        rc = (*client_fill_super)(sb);
-                       /* c_f_s will call lustre_common_put_super on failure */
+                       /* c_f_s will call lustre_common_put_super on failure,
+                        * which takes care of the module reference.
+                        */
                }
        } else {
 #ifdef HAVE_SERVER_SUPPORT
@@ -1680,32 +1688,24 @@ out:
  * We can't call ll_fill_super by name because it lives in a module that
  * must be loaded after this one.
  */
-void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb))
+void lustre_register_super_ops(struct module *mod,
+                              int (*cfs)(struct super_block *sb),
+                              void (*ksc)(struct super_block *sb))
 {
+       spin_lock(&client_lock);
+       client_mod = mod;
        client_fill_super = cfs;
+       kill_super_cb = ksc;
+       spin_unlock(&client_lock);
 }
-EXPORT_SYMBOL(lustre_register_client_fill_super);
-
-void lustre_register_kill_super_cb(void (*cfs)(struct super_block *sb))
-{
-       kill_super_cb = cfs;
-}
-EXPORT_SYMBOL(lustre_register_kill_super_cb);
+EXPORT_SYMBOL(lustre_register_super_ops);
 
 /***************** FS registration ******************/
-#ifdef HAVE_FSTYPE_MOUNT
 static struct dentry *lustre_mount(struct file_system_type *fs_type, int flags,
                                   const char *devname, void *data)
 {
        return mount_nodev(fs_type, flags, data, lustre_fill_super);
 }
-#else
-static int lustre_get_sb(struct file_system_type *fs_type, int flags,
-                        const char *devname, void *data, struct vfsmount *mnt)
-{
-       return get_sb_nodev(fs_type, flags, data, lustre_fill_super, mnt);
-}
-#endif
 
 static void lustre_kill_super(struct super_block *sb)
 {
@@ -1731,11 +1731,7 @@ static void lustre_kill_super(struct super_block *sb)
 static struct file_system_type lustre_fs_type_tgt = {
        .owner          = THIS_MODULE,
        .name           = "lustre_tgt",
-#ifdef HAVE_FSTYPE_MOUNT
        .mount          = lustre_mount,
-#else
-       .get_sb         = lustre_get_sb,
-#endif
        .kill_sb        = lustre_kill_super,
        .fs_flags       = FS_REQUIRES_DEV | FS_RENAME_DOES_D_MOVE,
 };
@@ -1763,11 +1759,7 @@ do {                                                                         \
 static struct file_system_type lustre_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "lustre",
-#ifdef HAVE_FSTYPE_MOUNT
        .mount          = lustre_mount,
-#else
-       .get_sb         = lustre_get_sb,
-#endif
        .kill_sb        = lustre_kill_super,
        .fs_flags       = FS_RENAME_DOES_D_MOVE,
 };