These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / staging / lustre / lustre / obdclass / class_obd.c
index d4b74b6..3e9c246 100644 (file)
 #include "../include/cl_object.h"
 #include "llog_internal.h"
 
-
 struct obd_device *obd_devs[MAX_OBD_DEVICES];
 EXPORT_SYMBOL(obd_devs);
 struct list_head obd_types;
 DEFINE_RWLOCK(obd_dev_lock);
 
-__u64 obd_max_pages = 0;
-EXPORT_SYMBOL(obd_max_pages);
-__u64 obd_max_alloc = 0;
-EXPORT_SYMBOL(obd_max_alloc);
-__u64 obd_alloc;
-EXPORT_SYMBOL(obd_alloc);
-__u64 obd_pages;
-EXPORT_SYMBOL(obd_pages);
-static DEFINE_SPINLOCK(obd_updatemax_lock);
-
 /* The following are visible and mutable through /proc/sys/lustre/. */
-unsigned int obd_alloc_fail_rate = 0;
-EXPORT_SYMBOL(obd_alloc_fail_rate);
 unsigned int obd_debug_peer_on_timeout;
 EXPORT_SYMBOL(obd_debug_peer_on_timeout);
 unsigned int obd_dump_on_timeout;
@@ -78,14 +65,10 @@ atomic_t obd_dirty_pages;
 EXPORT_SYMBOL(obd_dirty_pages);
 unsigned int obd_timeout = OBD_TIMEOUT_DEFAULT;   /* seconds */
 EXPORT_SYMBOL(obd_timeout);
-unsigned int ldlm_timeout = LDLM_TIMEOUT_DEFAULT; /* seconds */
-EXPORT_SYMBOL(ldlm_timeout);
 unsigned int obd_timeout_set;
 EXPORT_SYMBOL(obd_timeout_set);
-unsigned int ldlm_timeout_set;
-EXPORT_SYMBOL(ldlm_timeout_set);
 /* Adaptive timeout defs here instead of ptlrpc module for /proc/sys/ access */
-unsigned int at_min = 0;
+unsigned int at_min;
 EXPORT_SYMBOL(at_min);
 unsigned int at_max = 600;
 EXPORT_SYMBOL(at_max);
@@ -136,25 +119,6 @@ int lustre_get_jobid(char *jobid)
 }
 EXPORT_SYMBOL(lustre_get_jobid);
 
-int obd_alloc_fail(const void *ptr, const char *name, const char *type,
-                  size_t size, const char *file, int line)
-{
-       if (ptr == NULL ||
-           (cfs_rand() & OBD_ALLOC_FAIL_MASK) < obd_alloc_fail_rate) {
-               CERROR("%s%salloc of %s (%llu bytes) failed at %s:%d\n",
-                      ptr ? "force " :"", type, name, (__u64)size, file,
-                      line);
-               CERROR("%llu total bytes and %llu total pages (%llu bytes) allocated by Lustre, %d total bytes by LNET\n",
-                      obd_memory_sum(),
-                      obd_pages_sum() << PAGE_CACHE_SHIFT,
-                      obd_pages_sum(),
-                      atomic_read(&libcfs_kmemory));
-               return 1;
-       }
-       return 0;
-}
-EXPORT_SYMBOL(obd_alloc_fail);
-
 static inline void obd_data2conn(struct lustre_handle *conn,
                                 struct obd_ioctl_data *data)
 {
@@ -168,7 +132,7 @@ static inline void obd_conn2data(struct obd_ioctl_data *data,
        data->ioc_cookie = conn->cookie;
 }
 
-int class_resolve_dev_name(__u32 len, const char *name)
+static int class_resolve_dev_name(__u32 len, const char *name)
 {
        int rc;
        int dev;
@@ -231,8 +195,8 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
                        err = -EINVAL;
                        goto out;
                }
-               OBD_ALLOC(lcfg, data->ioc_plen1);
-               if (lcfg == NULL) {
+               lcfg = kzalloc(data->ioc_plen1, GFP_NOFS);
+               if (!lcfg) {
                        err = -ENOMEM;
                        goto out;
                }
@@ -243,7 +207,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
                if (!err)
                        err = class_process_config(lcfg);
 
-               OBD_FREE(lcfg, data->ioc_plen1);
+               kfree(lcfg);
                goto out;
        }
 
@@ -438,7 +402,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
 } /* class_handle_ioctl */
 
 #define OBD_INIT_CHECK
-int obd_init_checks(void)
+static int obd_init_checks(void)
 {
        __u64 u64val, div64val;
        char buf[64];
@@ -474,7 +438,7 @@ int obd_init_checks(void)
                return -EOVERFLOW;
        }
        if (do_div(div64val, 256) != (u64val & 255)) {
-               CERROR("do_div(%#llx,256) != %llu\n", u64val, u64val &255);
+               CERROR("do_div(%#llx,256) != %llu\n", u64val, u64val & 255);
                return -EOVERFLOW;
        }
        if (u64val >> 8 != div64val) {
@@ -506,47 +470,20 @@ int obd_init_checks(void)
        return ret;
 }
 
-#if defined (CONFIG_PROC_FS)
 extern int class_procfs_init(void);
 extern int class_procfs_clean(void);
-#else
-static inline int class_procfs_init(void)
-{ return 0; }
-static inline int class_procfs_clean(void)
-{ return 0; }
-#endif
 
 static int __init init_obdclass(void)
 {
        int i, err;
-       int lustre_register_fs(void);
 
-       for (i = CAPA_SITE_CLIENT; i < CAPA_SITE_MAX; i++)
-               INIT_LIST_HEAD(&capa_list[i]);
+       int lustre_register_fs(void);
 
        LCONSOLE_INFO("Lustre: Build Version: "BUILD_VERSION"\n");
 
        spin_lock_init(&obd_types_lock);
        obd_zombie_impexp_init();
 
-       if (IS_ENABLED(CONFIG_PROC_FS)) {
-               obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM,
-                                                LPROCFS_STATS_FLAG_NONE |
-                                                LPROCFS_STATS_FLAG_IRQ_SAFE);
-
-               if (obd_memory == NULL) {
-                       CERROR("kmalloc of 'obd_memory' failed\n");
-                       return -ENOMEM;
-               }
-
-               lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT,
-                                    LPROCFS_CNTR_AVGMINMAX,
-                                    "memused", "bytes");
-               lprocfs_counter_init(obd_memory, OBD_MEMORY_PAGES_STAT,
-                                    LPROCFS_CNTR_AVGMINMAX,
-                                    "pagesused", "pages");
-       }
-
        err = obd_init_checks();
        if (err == -EOVERFLOW)
                return err;
@@ -580,12 +517,14 @@ static int __init init_obdclass(void)
        if (err)
                return err;
 
-       obd_sysctl_init();
-
        err = class_procfs_init();
        if (err)
                return err;
 
+       err = obd_sysctl_init();
+       if (err)
+               return err;
+
        err = lu_global_init();
        if (err)
                return err;
@@ -594,7 +533,6 @@ static int __init init_obdclass(void)
        if (err != 0)
                return err;
 
-
        err = llog_info_init();
        if (err)
                return err;
@@ -604,62 +542,20 @@ static int __init init_obdclass(void)
        return err;
 }
 
-void obd_update_maxusage(void)
-{
-       __u64 max1, max2;
-
-       max1 = obd_pages_sum();
-       max2 = obd_memory_sum();
-
-       spin_lock(&obd_updatemax_lock);
-       if (max1 > obd_max_pages)
-               obd_max_pages = max1;
-       if (max2 > obd_max_alloc)
-               obd_max_alloc = max2;
-       spin_unlock(&obd_updatemax_lock);
-}
-EXPORT_SYMBOL(obd_update_maxusage);
-
-#if defined (CONFIG_PROC_FS)
-__u64 obd_memory_max(void)
-{
-       __u64 ret;
-
-       spin_lock(&obd_updatemax_lock);
-       ret = obd_max_alloc;
-       spin_unlock(&obd_updatemax_lock);
-
-       return ret;
-}
-EXPORT_SYMBOL(obd_memory_max);
-
-__u64 obd_pages_max(void)
-{
-       __u64 ret;
-
-       spin_lock(&obd_updatemax_lock);
-       ret = obd_max_pages;
-       spin_unlock(&obd_updatemax_lock);
-
-       return ret;
-}
-EXPORT_SYMBOL(obd_pages_max);
-#endif
-
 /* liblustre doesn't call cleanup_obdclass, apparently.  we carry on in this
  * ifdef to the end of the file to cover module and versioning goo.*/
 static void cleanup_obdclass(void)
 {
        int i;
+
        int lustre_unregister_fs(void);
-       __u64 memory_leaked, pages_leaked;
-       __u64 memory_max, pages_max;
 
        lustre_unregister_fs();
 
        misc_deregister(&obd_psdev);
        for (i = 0; i < class_devno_max(); i++) {
                struct obd_device *obd = class_num2obd(i);
+
                if (obd && obd->obd_set_up &&
                    OBT(obd) && OBP(obd, detach)) {
                        /* XXX should this call generic detach otherwise? */
@@ -672,27 +568,12 @@ static void cleanup_obdclass(void)
        lu_global_fini();
 
        obd_cleanup_caches();
-       obd_sysctl_clean();
 
        class_procfs_clean();
 
        class_handle_cleanup();
        class_exit_uuidlist();
        obd_zombie_impexp_stop();
-
-       memory_leaked = obd_memory_sum();
-       pages_leaked = obd_pages_sum();
-
-       memory_max = obd_memory_max();
-       pages_max = obd_pages_max();
-
-       lprocfs_free_stats(&obd_memory);
-       CDEBUG((memory_leaked) ? D_ERROR : D_INFO,
-              "obd_memory max: %llu, leaked: %llu\n",
-              memory_max, memory_leaked);
-       CDEBUG((pages_leaked) ? D_ERROR : D_INFO,
-              "obd_memory_pages max: %llu, leaked: %llu\n",
-              pages_max, pages_leaked);
 }
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");