Whamcloud - gitweb
don't leak lov_lock if adding to global ost pool is failed.
authorshadow <shadow>
Fri, 20 Mar 2009 22:08:02 +0000 (22:08 +0000)
committershadow <shadow>
Fri, 20 Mar 2009 22:08:02 +0000 (22:08 +0000)
Branch b1_8
b=18868
i=johann
i=tappro

lustre/lov/lov_obd.c

index 83ebeec..4c76dae 100644 (file)
@@ -650,6 +650,13 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
                 RETURN(-ENOMEM);
         }
 
+        rc = lov_ost_pool_add(&lov->lov_packed, index, lov->lov_tgt_size);
+        if (rc) {
+                mutex_up(&lov->lov_lock);
+                OBD_FREE_PTR(tgt);
+                RETURN(rc);
+        }
+
         memset(tgt, 0, sizeof(*tgt));
         tgt->ltd_uuid = *uuidp;
         /* XXX - add a sanity check on the generation number. */
@@ -660,10 +667,6 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
         if (index >= lov->desc.ld_tgt_count)
                 lov->desc.ld_tgt_count = index + 1;
 
-        rc = lov_ost_pool_add(&lov->lov_packed, index, lov->lov_tgt_size);
-        if (rc)
-                RETURN(rc);
-
         mutex_up(&lov->lov_lock);
 
         CDEBUG(D_CONFIG, "idx=%d ltd_gen=%d ld_tgt_count=%d\n",
@@ -689,12 +692,12 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
         rc = lov_notify(obd, tgt->ltd_exp->exp_obd,
                         active ? OBD_NOTIFY_CONNECT : OBD_NOTIFY_INACTIVE,
                         (void *)&index);
-
 out:
         if (rc) {
-                CERROR("add failed (%d), deleting %s\n", rc,
+                /* connect or notify failed - we can try connect later
+                 * instead of complete delete target */
+                CERROR("connect or notify failed (%d) for %s\n", rc,
                        obd_uuid2str(&tgt->ltd_uuid));
-                lov_del_target(obd, index, 0, 0);
         }
         lov_putref(obd);
         RETURN(rc);