These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / staging / lustre / lustre / lov / lov_pool.c
index d96163d..b03827e 100644 (file)
@@ -64,10 +64,10 @@ void lov_pool_putref(struct pool_desc *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);
+               LASSERT(pool->pool_debugfs_entry == NULL);
                lov_ost_pool_free(&(pool->pool_rr.lqr_pool));
                lov_ost_pool_free(&(pool->pool_obds));
-               OBD_FREE_PTR(pool);
+               kfree(pool);
        }
 }
 
@@ -142,17 +142,16 @@ static void pool_hashrefcount_put_locked(struct cfs_hash *hs,
        lov_pool_putref_locked(pool);
 }
 
-cfs_hash_ops_t pool_hash_operations = {
+struct cfs_hash_ops pool_hash_operations = {
        .hs_hash        = pool_hashfn,
-       .hs_key  = pool_key,
+       .hs_key         = pool_key,
        .hs_keycmp      = pool_hashkey_keycmp,
        .hs_object      = pool_hashobject,
-       .hs_get  = pool_hashrefcount_get,
+       .hs_get         = pool_hashrefcount_get,
        .hs_put_locked  = pool_hashrefcount_put_locked,
 
 };
 
-#if defined (CONFIG_PROC_FS)
 /* ifdef needed for liblustre support */
 /*
  * pool /proc seq_file methods
@@ -210,7 +209,7 @@ static void *pool_proc_start(struct seq_file *s, loff_t *pos)
                return NULL;
        }
 
-       OBD_ALLOC_PTR(iter);
+       iter = kzalloc(sizeof(*iter), GFP_NOFS);
        if (!iter)
                return ERR_PTR(-ENOMEM);
        iter->magic = POOL_IT_MAGIC;
@@ -246,7 +245,7 @@ static void pool_proc_stop(struct seq_file *s, void *v)
                 * will work */
                s->private = iter->pool;
                lov_pool_putref(iter->pool);
-               OBD_FREE_PTR(iter);
+               kfree(iter);
        }
        return;
 }
@@ -269,7 +268,7 @@ static int pool_proc_show(struct seq_file *s, void *v)
        return 0;
 }
 
-static struct seq_operations pool_proc_ops = {
+static const struct seq_operations pool_proc_ops = {
        .start    = pool_proc_start,
        .next      = pool_proc_next,
        .stop      = pool_proc_stop,
@@ -283,7 +282,8 @@ static int pool_proc_open(struct inode *inode, struct file *file)
        rc = seq_open(file, &pool_proc_ops);
        if (!rc) {
                struct seq_file *s = file->private_data;
-               s->private = PDE_DATA(inode);
+
+               s->private = inode->i_private;
        }
        return rc;
 }
@@ -294,29 +294,6 @@ static struct file_operations pool_proc_operations = {
        .llseek  = seq_lseek,
        .release        = seq_release,
 };
-#endif /* CONFIG_PROC_FS */
-
-void lov_dump_pool(int level, struct pool_desc *pool)
-{
-       int i;
-
-       lov_pool_getref(pool);
-
-       CDEBUG(level, "pool "LOV_POOLNAMEF" has %d members\n",
-              pool->pool_name, pool->pool_obds.op_count);
-       down_read(&pool_tgt_rw_sem(pool));
-
-       for (i = 0; i < pool_tgt_count(pool) ; i++) {
-               if (!pool_tgt(pool, i) || !(pool_tgt(pool, i))->ltd_exp)
-                       continue;
-               CDEBUG(level, "pool "LOV_POOLNAMEF"[%d] = %s\n",
-                      pool->pool_name, i,
-                      obd_uuid2str(&((pool_tgt(pool, i))->ltd_uuid)));
-       }
-
-       up_read(&pool_tgt_rw_sem(pool));
-       lov_pool_putref(pool);
-}
 
 #define LOV_POOL_INIT_COUNT 2
 int lov_ost_pool_init(struct ost_pool *op, unsigned int count)
@@ -327,7 +304,7 @@ int lov_ost_pool_init(struct ost_pool *op, unsigned int count)
        op->op_count = 0;
        init_rwsem(&op->op_rw_sem);
        op->op_size = count;
-       OBD_ALLOC(op->op_array, op->op_size * sizeof(op->op_array[0]));
+       op->op_array = kcalloc(op->op_size, sizeof(op->op_array[0]), GFP_NOFS);
        if (op->op_array == NULL) {
                op->op_size = 0;
                return -ENOMEM;
@@ -347,13 +324,13 @@ int lov_ost_pool_extend(struct ost_pool *op, unsigned int min_count)
                return 0;
 
        new_size = max(min_count, 2 * op->op_size);
-       OBD_ALLOC(new, new_size * sizeof(op->op_array[0]));
+       new = kcalloc(new_size, sizeof(op->op_array[0]), GFP_NOFS);
        if (new == NULL)
                return -ENOMEM;
 
        /* copy old array to new one */
        memcpy(new, op->op_array, op->op_size * sizeof(op->op_array[0]));
-       OBD_FREE(op->op_array, op->op_size * sizeof(op->op_array[0]));
+       kfree(op->op_array);
        op->op_array = new;
        op->op_size = new_size;
        return 0;
@@ -411,7 +388,7 @@ int lov_ost_pool_free(struct ost_pool *op)
 
        down_write(&op->op_rw_sem);
 
-       OBD_FREE(op->op_array, op->op_size * sizeof(op->op_array[0]));
+       kfree(op->op_array);
        op->op_array = NULL;
        op->op_count = 0;
        op->op_size = 0;
@@ -420,7 +397,6 @@ int lov_ost_pool_free(struct ost_pool *op)
        return 0;
 }
 
-
 int lov_pool_new(struct obd_device *obd, char *poolname)
 {
        struct lov_obd *lov;
@@ -432,8 +408,8 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
        if (strlen(poolname) > LOV_MAXPOOLNAME)
                return -ENAMETOOLONG;
 
-       OBD_ALLOC_PTR(new_pool);
-       if (new_pool == NULL)
+       new_pool = kzalloc(sizeof(*new_pool), GFP_NOFS);
+       if (!new_pool)
                return -ENOMEM;
 
        strncpy(new_pool->pool_name, poolname, LOV_MAXPOOLNAME);
@@ -454,20 +430,21 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
 
        INIT_HLIST_NODE(&new_pool->pool_hash);
 
-#if defined (CONFIG_PROC_FS)
        /* we need this assert seq_file is not implemented for liblustre */
        /* get ref for /proc file */
        lov_pool_getref(new_pool);
-       new_pool->pool_proc_entry = lprocfs_add_simple(lov->lov_pool_proc_entry,
-                                                      poolname, new_pool,
-                                                      &pool_proc_operations);
-       if (IS_ERR(new_pool->pool_proc_entry)) {
-               CWARN("Cannot add proc pool entry "LOV_POOLNAMEF"\n", poolname);
-               new_pool->pool_proc_entry = NULL;
+       new_pool->pool_debugfs_entry = ldebugfs_add_simple(
+                                               lov->lov_pool_debugfs_entry,
+                                               poolname, new_pool,
+                                               &pool_proc_operations);
+       if (IS_ERR_OR_NULL(new_pool->pool_debugfs_entry)) {
+               CWARN("Cannot add debugfs pool entry "LOV_POOLNAMEF"\n",
+                     poolname);
+               new_pool->pool_debugfs_entry = NULL;
                lov_pool_putref(new_pool);
        }
-       CDEBUG(D_INFO, "pool %p - proc %p\n", new_pool, new_pool->pool_proc_entry);
-#endif
+       CDEBUG(D_INFO, "pool %p - proc %p\n",
+               new_pool, new_pool->pool_debugfs_entry);
 
        spin_lock(&obd->obd_dev_lock);
        list_add_tail(&new_pool->pool_list, &lov->lov_pool_list);
@@ -493,12 +470,12 @@ out_err:
        lov->lov_pool_count--;
        spin_unlock(&obd->obd_dev_lock);
 
-       lprocfs_remove(&new_pool->pool_proc_entry);
+       ldebugfs_remove(&new_pool->pool_debugfs_entry);
 
        lov_ost_pool_free(&new_pool->pool_rr.lqr_pool);
 out_free_pool_obds:
        lov_ost_pool_free(&new_pool->pool_obds);
-       OBD_FREE_PTR(new_pool);
+       kfree(new_pool);
        return rc;
 }
 
@@ -514,9 +491,9 @@ int lov_pool_del(struct obd_device *obd, char *poolname)
        if (pool == NULL)
                return -ENOENT;
 
-       if (pool->pool_proc_entry != NULL) {
-               CDEBUG(D_INFO, "proc entry %p\n", pool->pool_proc_entry);
-               lprocfs_remove(&pool->pool_proc_entry);
+       if (!IS_ERR_OR_NULL(pool->pool_debugfs_entry)) {
+               CDEBUG(D_INFO, "proc entry %p\n", pool->pool_debugfs_entry);
+               ldebugfs_remove(&pool->pool_debugfs_entry);
                lov_pool_putref(pool);
        }
 
@@ -531,7 +508,6 @@ int lov_pool_del(struct obd_device *obd, char *poolname)
        return 0;
 }
 
-
 int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname)
 {
        struct obd_uuid ost_uuid;
@@ -548,7 +524,6 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname)
 
        obd_str2uuid(&ost_uuid, ostname);
 
-
        /* search ost in lov array */
        obd_getref(obd);
        for (lov_idx = 0; lov_idx < lov->desc.ld_tgt_count; lov_idx++) {