Whamcloud - gitweb
branch: HEAD
[fs/lustre-release.git] / lustre / lov / lov_pool.c
index fe55794..f63fac7 100644 (file)
@@ -280,7 +280,7 @@ int lov_ost_pool_init(struct ost_pool *op, unsigned int count)
                 count = LOV_POOL_INIT_COUNT;
         op->op_array = NULL;
         op->op_count = 0;
-        op->op_rwlock = RW_LOCK_UNLOCKED;
+        rwlock_init(&op->op_rwlock);
         op->op_size = count;
         OBD_ALLOC(op->op_array, op->op_size * sizeof(op->op_array[0]));
         if (op->op_array == NULL) {
@@ -400,18 +400,16 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
                 GOTO(out_err, rc);
         }
 
-        spin_lock(&obd->obd_dev_lock);
-        /* check if pool already exists */
-        if (lustre_hash_lookup(lov->lov_pools_hash_body, poolname) != NULL) {
-                spin_unlock(&obd->obd_dev_lock);
+        INIT_HLIST_NODE(&new_pool->pool_hash);
+        rc = lustre_hash_add_unique(lov->lov_pools_hash_body, poolname,
+                                    &new_pool->pool_hash);
+        if (rc) {
                 lov_ost_pool_free(&new_pool->pool_rr.lqr_pool);
                 lov_ost_pool_free(&new_pool->pool_obds);
                 GOTO(out_err, rc = -EEXIST);
         }
 
-        INIT_HLIST_NODE(&new_pool->pool_hash);
-        lustre_hash_add_unique(lov->lov_pools_hash_body, poolname,
-                               &new_pool->pool_hash);
+        spin_lock(&obd->obd_dev_lock);
         list_add_tail(&new_pool->pool_list, &lov->lov_pool_list);
         lov->lov_pool_count++;
         spin_unlock(&obd->obd_dev_lock);