Whamcloud - gitweb
- slightly better error handling in mountconf and ldiskfs osd
authoralex <alex>
Tue, 24 Feb 2009 19:45:47 +0000 (19:45 +0000)
committeralex <alex>
Tue, 24 Feb 2009 19:45:47 +0000 (19:45 +0000)
lustre/obdclass/obd_mount.c
lustre/osd/osd_handler.c

index ceb19b0..a390214 100644 (file)
@@ -1422,12 +1422,12 @@ static struct lu_device *try_start_osd(struct lustre_mount_data *lmd,
                                        char *typename,
                                        unsigned long s_flags)
 {
-        struct obd_type       *type;
+        struct obd_type       *type = NULL;
         struct lu_device_type *ldt;
         struct lu_device      *d = NULL;
         struct dt_device      *dt;
         struct lu_env          env;
-        int                    rc;
+        int                    rc = 0;
         struct                 lustre_cfg *lcfg;
         struct                 lustre_cfg_bufs bufs;
 
@@ -1470,11 +1470,21 @@ static struct lu_device *try_start_osd(struct lustre_mount_data *lmd,
         rc = dt->dd_lu_dev.ld_ops->ldo_process_config(&env, d, lcfg);
         lustre_cfg_free(lcfg);
 
+        if (rc)
+                GOTO(out, rc);
+
         lu_device_get(d);
         lu_ref_add(&d->ld_reference, "lu-stack", &lu_site_init);
 out_type:
 out_alloc:
 out:
+        if (rc) {
+                if (d)
+                        ldt->ldt_ops->ldto_device_free(&env, d);
+                if (type)
+                        class_put_type(type);
+                d = ERR_PTR(rc);
+        }
         lu_env_fini(&env);
         RETURN(d);
 }
@@ -1593,10 +1603,11 @@ static struct dt_device *server_kernel_mount(struct super_block *sb)
         if (rc == -ENOENT) {
                 /* no configuration found, use disk label */
                 stop_temp_site(sb);
-        } else
+        } else {
                 LASSERT(rc == 0);
+        }
 
-        RETURN(lu2dt_dev(mdev->mcf_bottom));
+        RETURN(lu2dt_dev(dev));
 
         /* In the past, we have always used flags = 0.
            Note ext3/ldiskfs can't be mounted ro. */
index ccff18f..7a6dcdd 100644 (file)
@@ -3638,15 +3638,18 @@ static int osd_mount(const struct lu_env *env,
         unsigned long             page, s_flags, ldd_flags;
         struct page              *__page;
         char                     *options = NULL;
+        int                      rc = 0;
 
         ENTRY;
 
         if (o->od_mnt != NULL)
                 RETURN(0);
         
+        o->od_obj_area = NULL;
+
         OBD_PAGE_ALLOC(__page, CFS_ALLOC_STD);
         if (__page == NULL)
-                RETURN(-ENOMEM);
+                GOTO(out, rc = -ENOMEM);
 
         s_flags = (unsigned long) lustre_cfg_buf(cfg, 1);
         opts = lustre_cfg_string(cfg, 2);
@@ -3662,7 +3665,8 @@ static int osd_mount(const struct lu_env *env,
 
         o->od_mnt = ll_kern_mount("ldiskfs", s_flags, dev, (void *)options);
         /* XXX: error handling */
-        LASSERTF(!IS_ERR(o->od_mnt), "%ld\n", PTR_ERR(o->od_mnt));
+        if (IS_ERR(o->od_mnt))
+                GOTO(out, rc = PTR_ERR(o->od_mnt));
 
         o->od_fsops = fsfilt_get_ops(mt_str(LDD_MT_LDISKFS));
         LASSERT(o->od_fsops);
@@ -3672,11 +3676,10 @@ static int osd_mount(const struct lu_env *env,
                 LCONSOLE_WARN("OSD: IAM mode enabled\n");
         } else
                 o->od_iop_mode = 1;
-
+out:
         OBD_PAGE_FREE(__page);
-        o->od_obj_area = NULL;
 
-        RETURN(0);
+        RETURN(rc);
 }
 
 static struct lu_device *osd_device_fini(const struct lu_env *env,