Whamcloud - gitweb
LU-5991 obd: fix mount error handing 59/12959/9
authorVladimir Saveliev <c17830@cray.com>
Thu, 15 Feb 2018 15:40:16 +0000 (18:40 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 6 Mar 2018 19:14:47 +0000 (19:14 +0000)
lustre_fill_super() allocates lsi and assumes that on failures lsi
will be freed by server_fill_super() or ll_fill_super().
- server_fill_super() does not free lsi when lsi_prepare() fails.
- ll_fill_super() does not free lsi when OBD_ALLOC_PTR(cfg) or
ll_init_sbi() fail.

osd_device_fini() needs osd_index_backup(). Otherwise
struct lustre_index_backup_unit-s leak if server_fill_super() fails
after osd_start().

Cray-bug-id: MRP-2229
Signed-off-by: Vladimir Saveliev <c17830@cray.com>
Change-Id: I366dc2b46a504a65b030bcbf687998dd0676f404
Reviewed-by: Sergey Cheremencev <c17829@cray.com>
Reviewed-by: Andriy Skulysh <c17819@cray.com>
Reviewed-on: https://review.whamcloud.com/12959
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/llite_lib.c
lustre/obdclass/obd_mount_server.c
lustre/osd-ldiskfs/osd_handler.c

index acf35e6..0f95175 100644 (file)
@@ -997,7 +997,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
 {
        struct  lustre_profile *lprof = NULL;
        struct  lustre_sb_info *lsi = s2lsi(sb);
-       struct  ll_sb_info *sbi;
+       struct  ll_sb_info *sbi = NULL;
        char    *dt = NULL, *md = NULL;
        char    *profilenm = get_profile_name(sb);
        struct config_llog_instance *cfg;
@@ -1010,19 +1010,16 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
 
        CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
 
+       try_module_get(THIS_MODULE);
+
        OBD_ALLOC_PTR(cfg);
        if (cfg == NULL)
-               RETURN(-ENOMEM);
-
-       try_module_get(THIS_MODULE);
+               GOTO(out_free, err = -ENOMEM);
 
        /* client additional sb info */
        lsi->lsi_llsbi = sbi = ll_init_sbi();
-       if (!sbi) {
-               module_put(THIS_MODULE);
-               OBD_FREE_PTR(cfg);
-               RETURN(-ENOMEM);
-       }
+       if (!sbi)
+               GOTO(out_free, err = -ENOMEM);
 
        err = ll_options(lsi->lsi_lmd->lmd_opts, &sbi->ll_flags);
        if (err)
@@ -1100,12 +1097,12 @@ out_free:
                OBD_FREE(dt, dt_len);
        if (lprof != NULL)
                class_put_profile(lprof);
+       if (cfg)
+               OBD_FREE_PTR(cfg);
        if (err)
                ll_put_super(sb);
        else if (sbi->ll_flags & LL_SBI_VERBOSE)
                LCONSOLE_WARN("Mounted %s\n", profilenm);
-
-       OBD_FREE_PTR(cfg);
        RETURN(err);
 } /* ll_fill_super */
 
@@ -1120,6 +1117,9 @@ void ll_put_super(struct super_block *sb)
        int next, force = 1, rc = 0;
         ENTRY;
 
+       if (!sbi)
+               GOTO(out_no_sbi, 0);
+
         CDEBUG(D_VFSTRACE, "VFS Op: sb %p - %s\n", sb, profilenm);
 
         cfg.cfg_instance = sb;
@@ -1182,7 +1182,7 @@ void ll_put_super(struct super_block *sb)
 
         ll_free_sbi(sb);
         lsi->lsi_llsbi = NULL;
-
+out_no_sbi:
        lustre_common_put_super(sb);
 
        cl_env_cache_purge(~0);
index 8441d5b..c65cb53 100644 (file)
@@ -1890,8 +1890,10 @@ int server_fill_super(struct super_block *sb)
        OBD_RACE(OBD_FAIL_TGT_MOUNT_RACE);
 
        rc = lsi_prepare(lsi);
-       if (rc)
+       if (rc) {
+               lustre_put_lsi(sb);
                RETURN(rc);
+       }
 
        /* Start low level OSD */
        rc = osd_start(lsi, sb->s_flags);
index 7bcf863..9519356 100644 (file)
@@ -7293,6 +7293,7 @@ static struct lu_device *osd_device_fini(const struct lu_env *env,
        struct osd_device *o = osd_dev(d);
        ENTRY;
 
+       osd_index_backup(env, o, false);
        osd_shutdown(env, o);
        osd_procfs_fini(o);
        osd_obj_map_fini(o);