Whamcloud - gitweb
LU-6142 lustre: change all 'struct seq_operations' to const
[fs/lustre-release.git] / lustre / lov / lov_pool.c
index ef941ab..73e2b6a 100644 (file)
@@ -65,7 +65,7 @@ static int pool_cmpfn(struct rhashtable_compare_arg *arg, const void *obj)
        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),
@@ -111,25 +111,25 @@ struct pool_iterator {
 
 static void *pool_proc_next(struct seq_file *s, void *v, loff_t *pos)
 {
-        struct pool_iterator *iter = (struct pool_iterator *)s->private;
-        int prev_idx;
+       struct pool_iterator *iter = (struct pool_iterator *)s->private;
+       int prev_idx;
 
        LASSERTF(iter->magic == POOL_IT_MAGIC, "%08X\n", iter->magic);
 
-        /* test if end of file */
-        if (*pos >= pool_tgt_count(iter->pool))
-                return NULL;
+       (*pos)++;
+       /* test if end of file */
+       if (*pos > pool_tgt_count(iter->pool))
+               return NULL;
 
-        /* iterate to find a non empty entry */
-        prev_idx = iter->idx;
-        iter->idx++;
+       /* iterate to find a non empty entry */
+       prev_idx = iter->idx;
+       iter->idx++;
        if (iter->idx >= pool_tgt_count(iter->pool)) {
-                iter->idx = prev_idx; /* we stay on the last entry */
-                return NULL;
-        }
-        (*pos)++;
-        /* return != NULL to continue */
-        return iter;
+               iter->idx = prev_idx; /* we stay on the last entry */
+               return NULL;
+       }
+       /* return != NULL to continue */
+       return iter;
 }
 
 static void *pool_proc_start(struct seq_file *s, loff_t *pos)
@@ -204,11 +204,11 @@ static int pool_proc_show(struct seq_file *s, void *v)
         return 0;
 }
 
-static struct seq_operations pool_proc_ops = {
-        .start          = pool_proc_start,
-        .next           = pool_proc_next,
-        .stop           = pool_proc_stop,
-        .show           = pool_proc_show,
+static const struct seq_operations pool_proc_ops = {
+       .start          = pool_proc_start,
+       .next           = pool_proc_next,
+       .stop           = pool_proc_stop,
+       .show           = pool_proc_show,
 };
 
 static int pool_proc_open(struct inode *inode, struct file *file)
@@ -223,11 +223,11 @@ static int pool_proc_open(struct inode *inode, struct file *file)
         return rc;
 }
 
-static struct file_operations pool_proc_operations = {
-        .open           = pool_proc_open,
-        .read           = seq_read,
-        .llseek         = seq_lseek,
-        .release        = seq_release,
+const static struct file_operations pool_proc_operations = {
+       .open           = pool_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = seq_release,
 };
 #endif /* CONFIG_PROC_FS */
 
@@ -458,6 +458,22 @@ out_err:
        return rc;
 }
 
+struct pool_desc *lov_pool_find(struct obd_device *obd, char *poolname)
+{
+       struct pool_desc *pool;
+       struct lov_obd *lov = &obd->u.lov;
+
+       rcu_read_lock();
+       pool = rhashtable_lookup(&lov->lov_pools_hash_body,
+                                poolname,
+                                pools_hash_params);
+       if (pool && !atomic_inc_not_zero(&pool->pool_refcount))
+               pool = NULL;
+       rcu_read_unlock();
+
+       return pool;
+}
+
 int lov_pool_del(struct obd_device *obd, char *poolname)
 {
         struct lov_obd *lov;