return strcmp(pool_name, pool->pool_name);
}
-const struct rhashtable_params pools_hash_params = {
+static const struct rhashtable_params pools_hash_params = {
.key_len = 1, /* actually variable */
.key_offset = offsetof(struct pool_desc, pool_name),
.head_offset = offsetof(struct pool_desc, pool_hash),
rhashtable_free_and_destroy(tbl, pools_hash_exit, NULL);
}
+bool lod_pool_exists(struct lod_device *lod, char *poolname)
+{
+ struct pool_desc *pool;
+
+ rcu_read_lock();
+ pool = rhashtable_lookup(&lod->lod_pools_hash_body,
+ poolname,
+ pools_hash_params);
+ rcu_read_unlock();
+ return pool != NULL;
+}
+
+static struct pool_desc *lod_pool_find(struct lod_device *lod, char *poolname)
+{
+ struct pool_desc *pool;
+
+ rcu_read_lock();
+ pool = rhashtable_lookup(&lod->lod_pools_hash_body,
+ poolname,
+ pools_hash_params);
+ if (pool && !atomic_inc_not_zero(&pool->pool_refcount))
+ pool = NULL;
+ rcu_read_unlock();
+ return pool;
+}
/**
* Allocate a new pool for the specified device.
*
int rc = -EINVAL;
ENTRY;
- rcu_read_lock();
- pool = rhashtable_lookup(&lod->lod_pools_hash_body, poolname,
- pools_hash_params);
- if (pool && !atomic_inc_not_zero(&pool->pool_refcount))
- pool = NULL;
- rcu_read_unlock();
+ pool = lod_pool_find(lod, poolname);
if (!pool)
RETURN(-ENOENT);
ENTRY;
/* lookup and kill hash reference */
- rcu_read_lock();
- pool = rhashtable_lookup(&lod->lod_pools_hash_body, poolname,
- pools_hash_params);
- if (pool && !atomic_inc_not_zero(&pool->pool_refcount))
- pool = NULL;
- rcu_read_unlock();
+ pool = lod_pool_find(lod, poolname);
if (!pool)
RETURN(-ENOENT);
pool = NULL;
if (poolname[0] != '\0') {
- rcu_read_lock();
- pool = rhashtable_lookup(&lod->lod_pools_hash_body, poolname,
- pools_hash_params);
- if (pool && !atomic_inc_not_zero(&pool->pool_refcount))
- pool = NULL;
- rcu_read_unlock();
+ pool = lod_pool_find(lod, poolname);
if (!pool)
CDEBUG(D_CONFIG,
"%s: request for an unknown pool (" LOV_POOLNAMEF ")\n",
if (!poolname || !*poolname || (*poolname)[0] == '\0')
return;
repeat:
- rcu_read_lock();
- pool = rhashtable_lookup(&lod->lod_pools_hash_body, *poolname,
- pools_hash_params);
- if (pool && !atomic_inc_not_zero(&pool->pool_refcount))
- pool = NULL;
- rcu_read_unlock();
+ pool = lod_pool_find(lod, *poolname);
if (!pool)
return;
size_t count, loff_t *off)
{
struct seq_file *m = file->private_data;
- struct pool_desc *tgt, *pool = m->private;
+ struct pool_desc *pool = m->private;
struct lod_device *lod;
LASSERT(pool != NULL);
pool->pool_spill_target[count] = '\0';
if (strcmp(pool->pool_name, pool->pool_spill_target) == 0)
return -ELOOP;
- rcu_read_lock();
- tgt = rhashtable_lookup(&lod->lod_pools_hash_body,
- pool->pool_spill_target,
- pools_hash_params);
- rcu_read_unlock();
- if (!tgt) {
+ if (!lod_pool_exists(lod, pool->pool_spill_target)) {
pool->pool_spill_target[0] = '\0';
pool->pool_spill_expire = 0;
return -ENODEV;