Whamcloud - gitweb
LU-4975 ofd: documenting the ofd_fs.c
[fs/lustre-release.git] / lustre / lov / lov_pool.c
index 2c16d9d..88cf76a 100644 (file)
 
 static void lov_pool_getref(struct pool_desc *pool)
 {
-        CDEBUG(D_INFO, "pool %p\n", pool);
-        cfs_atomic_inc(&pool->pool_refcount);
+       CDEBUG(D_INFO, "pool %p\n", pool);
+       atomic_inc(&pool->pool_refcount);
 }
 
 void lov_pool_putref(struct pool_desc *pool) 
 {
-        CDEBUG(D_INFO, "pool %p\n", pool);
-        if (cfs_atomic_dec_and_test(&pool->pool_refcount)) {
-                LASSERT(cfs_hlist_unhashed(&pool->pool_hash));
-                LASSERT(cfs_list_empty(&pool->pool_list));
-                LASSERT(pool->pool_proc_entry == NULL);
-                lov_ost_pool_free(&(pool->pool_obds));
-                OBD_FREE_PTR(pool);
-                EXIT;
-        }
+       CDEBUG(D_INFO, "pool %p\n", pool);
+       if (atomic_dec_and_test(&pool->pool_refcount)) {
+               LASSERT(hlist_unhashed(&pool->pool_hash));
+               LASSERT(list_empty(&pool->pool_list));
+               LASSERT(pool->pool_proc_entry == NULL);
+               lov_ost_pool_free(&(pool->pool_obds));
+               OBD_FREE_PTR(pool);
+               EXIT;
+       }
 }
 
 void lov_pool_putref_locked(struct pool_desc *pool)
 {
-        CDEBUG(D_INFO, "pool %p\n", pool);
-        LASSERT(cfs_atomic_read(&pool->pool_refcount) > 1);
+       CDEBUG(D_INFO, "pool %p\n", pool);
+       LASSERT(atomic_read(&pool->pool_refcount) > 1);
 
-        cfs_atomic_dec(&pool->pool_refcount);
+       atomic_dec(&pool->pool_refcount);
 }
 
 /*
@@ -106,43 +106,44 @@ static __u32 pool_hashfn(cfs_hash_t *hash_body, const void *key, unsigned mask)
         return (result % mask);
 }
 
-static void *pool_key(cfs_hlist_node_t *hnode)
+static void *pool_key(struct hlist_node *hnode)
 {
         struct pool_desc *pool;
 
-        pool = cfs_hlist_entry(hnode, struct pool_desc, pool_hash);
+       pool = hlist_entry(hnode, struct pool_desc, pool_hash);
         return (pool->pool_name);
 }
 
-static int pool_hashkey_keycmp(const void *key, cfs_hlist_node_t *compared_hnode)
+static int
+pool_hashkey_keycmp(const void *key, struct hlist_node *compared_hnode)
 {
         char *pool_name;
         struct pool_desc *pool;
 
         pool_name = (char *)key;
-        pool = cfs_hlist_entry(compared_hnode, struct pool_desc, pool_hash);
+       pool = hlist_entry(compared_hnode, struct pool_desc, pool_hash);
         return !strncmp(pool_name, pool->pool_name, LOV_MAXPOOLNAME);
 }
 
-static void *pool_hashobject(cfs_hlist_node_t *hnode)
+static void *pool_hashobject(struct hlist_node *hnode)
 {
-        return cfs_hlist_entry(hnode, struct pool_desc, pool_hash);
+       return hlist_entry(hnode, struct pool_desc, pool_hash);
 }
 
-static void pool_hashrefcount_get(cfs_hash_t *hs, cfs_hlist_node_t *hnode)
+static void pool_hashrefcount_get(cfs_hash_t *hs, struct hlist_node *hnode)
 {
         struct pool_desc *pool;
 
-        pool = cfs_hlist_entry(hnode, struct pool_desc, pool_hash);
+       pool = hlist_entry(hnode, struct pool_desc, pool_hash);
         lov_pool_getref(pool);
 }
 
 static void pool_hashrefcount_put_locked(cfs_hash_t *hs,
-                                         cfs_hlist_node_t *hnode)
+                                        struct hlist_node *hnode)
 {
         struct pool_desc *pool;
 
-        pool = cfs_hlist_entry(hnode, struct pool_desc, pool_hash);
+       pool = hlist_entry(hnode, struct pool_desc, pool_hash);
         lov_pool_putref_locked(pool);
 }
 
@@ -448,18 +449,18 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
         if (new_pool == NULL)
                 RETURN(-ENOMEM);
 
-        strncpy(new_pool->pool_name, poolname, LOV_MAXPOOLNAME);
-        new_pool->pool_name[LOV_MAXPOOLNAME] = '\0';
+       strncpy(new_pool->pool_name, poolname, LOV_MAXPOOLNAME);
+       new_pool->pool_name[LOV_MAXPOOLNAME] = '\0';
        new_pool->pool_lobd = obd;
-        /* ref count init to 1 because when created a pool is always used
-         * up to deletion
-         */
-        cfs_atomic_set(&new_pool->pool_refcount, 1);
-        rc = lov_ost_pool_init(&new_pool->pool_obds, 0);
-        if (rc)
-               GOTO(out_err, rc);
+       /* ref count init to 1 because when created a pool is always used
+        * up to deletion
+        */
+       atomic_set(&new_pool->pool_refcount, 1);
+       rc = lov_ost_pool_init(&new_pool->pool_obds, 0);
+       if (rc)
+               GOTO(out_err, rc);
 
-        CFS_INIT_HLIST_NODE(&new_pool->pool_hash);
+       INIT_HLIST_NODE(&new_pool->pool_hash);
 
 #ifdef LPROCFS
         /* we need this assert seq_file is not implementated for liblustre */
@@ -481,7 +482,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
 #endif
 
        spin_lock(&obd->obd_dev_lock);
-       cfs_list_add_tail(&new_pool->pool_list, &lov->lov_pool_list);
+       list_add_tail(&new_pool->pool_list, &lov->lov_pool_list);
        lov->lov_pool_count++;
        spin_unlock(&obd->obd_dev_lock);
 
@@ -498,7 +499,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
 
 out_err:
        spin_lock(&obd->obd_dev_lock);
-       cfs_list_del_init(&new_pool->pool_list);
+       list_del_init(&new_pool->pool_list);
        lov->lov_pool_count--;
        spin_unlock(&obd->obd_dev_lock);
         lprocfs_remove(&new_pool->pool_proc_entry);
@@ -528,7 +529,7 @@ int lov_pool_del(struct obd_device *obd, char *poolname)
         }
 
        spin_lock(&obd->obd_dev_lock);
-       cfs_list_del_init(&pool->pool_list);
+       list_del_init(&pool->pool_list);
        lov->lov_pool_count--;
        spin_unlock(&obd->obd_dev_lock);
 
@@ -627,51 +628,3 @@ out:
         lov_pool_putref(pool);
         return rc;
 }
-
-int lov_check_index_in_pool(__u32 idx, struct pool_desc *pool)
-{
-        int i, rc;
-        ENTRY;
-
-        /* caller may no have a ref on pool if it got the pool
-         * without calling lov_find_pool() (e.g. go through the lov pool
-         * list)
-         */
-        lov_pool_getref(pool);
-
-       down_read(&pool_tgt_rw_sem(pool));
-
-        for (i = 0; i < pool_tgt_count(pool); i++) {
-                if (pool_tgt_array(pool)[i] == idx)
-                        GOTO(out, rc = 0);
-        }
-        rc = -ENOENT;
-        EXIT;
-out:
-       up_read(&pool_tgt_rw_sem(pool));
-
-        lov_pool_putref(pool);
-        return rc;
-}
-
-struct pool_desc *lov_find_pool(struct lov_obd *lov, char *poolname)
-{
-        struct pool_desc *pool;
-
-        pool = NULL;
-        if (poolname[0] != '\0') {
-                pool = cfs_hash_lookup(lov->lov_pools_hash_body, poolname);
-                if (pool == NULL)
-                        CWARN("Request for an unknown pool ("LOV_POOLNAMEF")\n",
-                              poolname);
-                if ((pool != NULL) && (pool_tgt_count(pool) == 0)) {
-                        CWARN("Request for an empty pool ("LOV_POOLNAMEF")\n",
-                               poolname);
-                        /* pool is ignored, so we remove ref on it */
-                        lov_pool_putref(pool);
-                        pool = NULL;
-                }
-        }
-        return pool;
-}
-