Whamcloud - gitweb
LU-2158 lvfs: move obdclass related functions to obclass
authorJames Simmons <uja.ornl@gmail.com>
Tue, 19 Feb 2013 17:29:29 +0000 (12:29 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 20 Feb 2013 03:42:32 +0000 (22:42 -0500)
Currently a lot of functions exist in the lvfs layer
that really belongs to different parts of the stack.
This patch moves obdclass specific code that is located
in the lvfs layer into the proper location.

Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: I5be4dede1afdbbc4af0157cbcd13a5133ce7a1db
Reviewed-on: http://review.whamcloud.com/5250
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lvfs/lvfs_lib.c
lustre/lvfs/lvfs_linux.c
lustre/obdclass/class_obd.c

index 82e930b..31c2d51 100644 (file)
 #include <lustre_lib.h>
 #include <lprocfs_status.h>
 
-unsigned int obd_alloc_fail_rate = 0;
-
-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 ("LPU64" bytes) failed at %s:%d\n",
-                       ptr ? "force " :"", type, name, (__u64)size, file,
-                       line);
-                CERROR(LPU64" total bytes and "LPU64" total pages "
-                       "("LPU64" bytes) allocated by Lustre, "
-                       "%d total bytes by LNET\n",
-                       obd_memory_sum(),
-                       obd_pages_sum() << CFS_PAGE_SHIFT,
-                       obd_pages_sum(),
-                       cfs_atomic_read(&libcfs_kmemory));
-                return 1;
-        }
-        return 0;
-}
-EXPORT_SYMBOL(obd_alloc_fail);
-
 #ifdef LPROCFS
 void lprocfs_counter_add(struct lprocfs_stats *stats, int idx, long amount)
 {
@@ -198,5 +175,3 @@ int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid)
 }
 EXPORT_SYMBOL(lprocfs_stats_alloc_one);
 #endif  /* LPROCFS */
-
-EXPORT_SYMBOL(obd_alloc_fail_rate);
index 525e660..a4f9340 100644 (file)
 #include <obd.h>
 #include <lustre_lib.h>
 
-__u64 obd_max_pages = 0;
-__u64 obd_max_alloc = 0;
 struct lprocfs_stats *obd_memory = NULL;
 EXPORT_SYMBOL(obd_memory);
-DEFINE_SPINLOCK(obd_updatemax_lock);
 /* refine later and change to seqlock or simlar from libcfs */
 
 /* Debugging check only needed during development */
@@ -246,47 +243,6 @@ struct l_file *l_dentry_open(struct lvfs_run_ctxt *ctxt, struct l_dentry *de,
 }
 EXPORT_SYMBOL(l_dentry_open);
 
-void obd_update_maxusage()
-{
-       __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);
-
-__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);
-
 #ifdef LPROCFS
 __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
                          struct lprocfs_counter_header *header,
index d9355ad..3470ba6 100644 (file)
@@ -60,14 +60,17 @@ EXPORT_SYMBOL(obd_devs);
 cfs_list_t obd_types;
 DEFINE_RWLOCK(obd_dev_lock);
 
-#ifndef __KERNEL__
 __u64 obd_max_pages = 0;
 __u64 obd_max_alloc = 0;
+#ifndef __KERNEL__
 __u64 obd_alloc;
 __u64 obd_pages;
 #endif
+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;
@@ -162,6 +165,27 @@ 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 ("LPU64" bytes) failed at %s:%d\n",
+                      ptr ? "force " :"", type, name, (__u64)size, file,
+                      line);
+               CERROR(LPU64" total bytes and "LPU64" total pages "
+                      "("LPU64" bytes) allocated by Lustre, "
+                      "%d total bytes by LNET\n",
+                      obd_memory_sum(),
+                      obd_pages_sum() << CFS_PAGE_SHIFT,
+                      obd_pages_sum(),
+                       cfs_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)
 {
@@ -588,6 +612,48 @@ int 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);
+
+#ifdef LPROCFS
+__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.*/
 #ifdef __KERNEL__