Whamcloud - gitweb
Call cmm_device_free() in the failure path of cmm_device_alloc().
authornikita <nikita>
Sat, 18 Oct 2008 15:22:51 +0000 (15:22 +0000)
committernikita <nikita>
Sat, 18 Oct 2008 15:22:51 +0000 (15:22 +0000)
b=16450

lustre/ChangeLog
lustre/cmm/cmm_device.c

index a7f1479..f3df71e 100644 (file)
@@ -1458,7 +1458,12 @@ Bugzilla   : 16450
 Description: OSD_COUNTERS-mandatory
 Details    : Make previously optional ->oti_{w,r}_locks sanity checks mandatory
             to simplify the code.
-       
+
+Severity   : normal
+Bugzilla   : 16450
+Description: simplify cmm_device freeing logic.
+Details    : Call cmm_device_free() in the failure path of cmm_device_alloc().
+
 --------------------------------------------------------------------------------
 
 2007-08-10         Cluster File Systems, Inc. <info@clusterfs.com>
index aef1da6..3cf494b 100644 (file)
@@ -359,6 +359,24 @@ int cmm_upcall(const struct lu_env *env, struct md_device *md,
         RETURN(rc);
 }
 
+static struct lu_device *cmm_device_free(const struct lu_env *env,
+                                         struct lu_device *d)
+{
+        struct cmm_device *m = lu2cmm_dev(d);
+        struct lu_device  *next = md2lu_dev(m->cmm_child);
+        ENTRY;
+
+        LASSERT(m->cmm_tgt_count == 0);
+        LASSERT(list_empty(&m->cmm_targets));
+        if (m->cmm_fld != NULL) {
+                OBD_FREE_PTR(m->cmm_fld);
+                m->cmm_fld = NULL;
+        }
+        md_device_fini(&m->cmm_md_dev);
+        OBD_FREE_PTR(m);
+        RETURN(next);
+}
+
 static struct lu_device *cmm_device_alloc(const struct lu_env *env,
                                           struct lu_device_type *t,
                                           struct lustre_cfg *cfg)
@@ -378,32 +396,12 @@ static struct lu_device *cmm_device_alloc(const struct lu_env *env,
                 l->ld_ops = &cmm_lu_ops;
 
                 OBD_ALLOC_PTR(m->cmm_fld);
-                if (!m->cmm_fld)
-                        GOTO(out_free_cmm, l = ERR_PTR(-ENOMEM));
+                if (!m->cmm_fld) {
+                        cmm_device_free(env, l);
+                        l = ERR_PTR(-ENOMEM);
         }
-
-        RETURN(l);
-out_free_cmm:
-        OBD_FREE_PTR(m);
-        return l;
-}
-
-static struct lu_device *cmm_device_free(const struct lu_env *env,
-                                         struct lu_device *d)
-{
-        struct cmm_device *m = lu2cmm_dev(d);
-        struct lu_device  *next = md2lu_dev(m->cmm_child);
-        ENTRY;
-
-        LASSERT(m->cmm_tgt_count == 0);
-        LASSERT(list_empty(&m->cmm_targets));
-        if (m->cmm_fld != NULL) {
-                OBD_FREE_PTR(m->cmm_fld);
-                m->cmm_fld = NULL;
         }
-        md_device_fini(&m->cmm_md_dev);
-        OBD_FREE_PTR(m);
-        RETURN(next);
+        RETURN(l);
 }
 
 /* context key constructor/destructor: cmm_key_init, cmm_key_fini */