aboutsummaryrefslogtreecommitdiffstats
path: root/module/spl
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2009-05-20 10:08:37 -0700
committerBrian Behlendorf <[email protected]>2009-05-20 10:08:37 -0700
commit96dded38442684319305082aa2ac7e25f7f414da (patch)
treea541f01e4f60b05adb9931088c2080f659003786 /module/spl
parentbf338d8d09b410884be526ed4f11b6030244dbfa (diff)
SLES10 Fixes (part 2):
- Configure check, the div64_64() function was renamed to div64_u64() as of 2.6.26. - Configure check, the global_page_state() fuction was introduced in 2.6.18 kernels. The earlier 2.6.16 based SLES10 must not try and use it, thankfully get_zone_counts() is still available. - To simplify debugging poison all symbols aquired dynamically using spl_kallsyms_lookup_name() with SYMBOL_POISON. - Add console messages when the user mode helpers fail. - spl_kmem_init_globals() use bit shifts instead of division. - When the monotonic clock is unavailable __gethrtime() must perform the HZ division as an 'unsigned long long' because the SPL only implements __udivdi3(), and not __divdi3() for 'long long' division on 32-bit arches.
Diffstat (limited to 'module/spl')
-rw-r--r--module/spl/spl-generic.c42
-rw-r--r--module/spl/spl-kmem.c24
-rw-r--r--module/spl/spl-proc.c2
-rw-r--r--module/spl/spl-time.c4
4 files changed, 41 insertions, 31 deletions
diff --git a/module/spl/spl-generic.c b/module/spl/spl-generic.c
index 76a8de472..fe6350079 100644
--- a/module/spl/spl-generic.c
+++ b/module/spl/spl-generic.c
@@ -55,7 +55,7 @@ int p0 = 0;
EXPORT_SYMBOL(p0);
#ifndef HAVE_KALLSYMS_LOOKUP_NAME
-kallsyms_lookup_name_t spl_kallsyms_lookup_name_fn = NULL;
+kallsyms_lookup_name_t spl_kallsyms_lookup_name_fn = SYMBOL_POISON;
#endif
int
@@ -96,10 +96,12 @@ EXPORT_SYMBOL(highbit);
#if BITS_PER_LONG == 32
uint64_t __udivdi3(uint64_t dividend, uint64_t divisor)
{
-#ifdef HAVE_DIV64_64
+#if defined(HAVE_DIV64_64) /* 2.6.22 - 2.6.25 API */
return div64_64(dividend, divisor);
+#elif defined(HAVE_DIV64_U64) /* 2.6.26 - 2.6.x API */
+ return div64_u64(dividend, divisor);
#else
- /* Taken from a 2.6.24 kernel. */
+ /* Implementation from 2.6.30 kernel */
uint32_t high, d;
high = divisor >> 32;
@@ -111,10 +113,8 @@ uint64_t __udivdi3(uint64_t dividend, uint64_t divisor)
} else
d = divisor;
- do_div(dividend, d);
-
- return dividend;
-#endif
+ return do_div64(dividend, d);
+#endif /* HAVE_DIV64_64, HAVE_DIV64_U64 */
}
EXPORT_SYMBOL(__udivdi3);
@@ -126,12 +126,12 @@ uint64_t __umoddi3(uint64_t dividend, uint64_t divisor)
return dividend - divisor * (dividend / divisor);
}
EXPORT_SYMBOL(__umoddi3);
-#endif
+#endif /* BITS_PER_LONG */
/* NOTE: The strtoxx behavior is solely based on my reading of the Solaris
* ddi_strtol(9F) man page. I have not verified the behavior of these
* functions against their Solaris counterparts. It is possible that I
- * may have misinterpretted the man page or the man page is incorrect.
+ * may have misinterpreted the man page or the man page is incorrect.
*/
int ddi_strtoul(const char *, char **, int, unsigned long *);
int ddi_strtol(const char *, char **, int, long *);
@@ -248,14 +248,20 @@ set_hostid(void)
"TERM=linux",
"PATH=/sbin:/usr/sbin:/bin:/usr/bin",
NULL };
+ int rc;
/* Doing address resolution in the kernel is tricky and just
* not a good idea in general. So to set the proper 'hw_serial'
* use the usermodehelper support to ask '/bin/sh' to run
* '/usr/bin/hostid' and redirect the result to /proc/sys/spl/hostid
- * for us to use. It's a horific solution but it will do for now.
+ * for us to use. It's a horrific solution but it will do for now.
*/
- return call_usermodehelper(sh_path, argv, envp, 1);
+ rc = call_usermodehelper(sh_path, argv, envp, 1);
+ if (rc)
+ printk("SPL: Failed user helper '%s %s %s', rc = %d\n",
+ argv[0], argv[1], argv[2], rc);
+
+ return rc;
}
uint32_t
@@ -273,9 +279,7 @@ zone_get_hostid(void *zone)
}
EXPORT_SYMBOL(zone_get_hostid);
-#ifdef HAVE_KALLSYMS_LOOKUP_NAME
-#define set_kallsyms_lookup_name() (0)
-#else
+#ifndef HAVE_KALLSYMS_LOOKUP_NAME
/*
* Because kallsyms_lookup_name() is no longer exported in the
* mainline kernel we are forced to resort to somewhat drastic
@@ -303,9 +307,10 @@ set_kallsyms_lookup_name(void)
rc = call_usermodehelper(sh_path, argv, envp, 1);
if (rc)
- return rc;
+ printk("SPL: Failed user helper '%s %s %s', rc = %d\n",
+ argv[0], argv[1], argv[2], rc);
- return spl_kmem_init_kallsyms_lookup();
+ return rc;
}
#endif
@@ -337,8 +342,13 @@ static int __init spl_init(void)
if ((rc = set_hostid()))
GOTO(out7, rc = -EADDRNOTAVAIL);
+#ifndef HAVE_KALLSYMS_LOOKUP_NAME
if ((rc = set_kallsyms_lookup_name()))
GOTO(out7, rc = -EADDRNOTAVAIL);
+#endif /* HAVE_KALLSYMS_LOOKUP_NAME */
+
+ if ((rc = spl_kmem_init_kallsyms_lookup()))
+ GOTO(out7, rc);
printk("SPL: Loaded Solaris Porting Layer v%s\n", SPL_META_VERSION);
RETURN(rc);
diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c
index 6723dcd08..706691929 100644
--- a/module/spl/spl-kmem.c
+++ b/module/spl/spl-kmem.c
@@ -80,29 +80,30 @@ vmem_t *zio_arena = NULL;
EXPORT_SYMBOL(zio_arena);
#ifndef HAVE_GET_VMALLOC_INFO
-get_vmalloc_info_t get_vmalloc_info_fn = NULL;
+get_vmalloc_info_t get_vmalloc_info_fn = SYMBOL_POISON;
EXPORT_SYMBOL(get_vmalloc_info_fn);
#endif /* HAVE_GET_VMALLOC_INFO */
#ifndef HAVE_FIRST_ONLINE_PGDAT
-first_online_pgdat_t first_online_pgdat_fn = NULL;
+first_online_pgdat_t first_online_pgdat_fn = SYMBOL_POISON;
EXPORT_SYMBOL(first_online_pgdat_fn);
#endif /* HAVE_FIRST_ONLINE_PGDAT */
#ifndef HAVE_NEXT_ONLINE_PGDAT
-next_online_pgdat_t next_online_pgdat_fn = NULL;
+next_online_pgdat_t next_online_pgdat_fn = SYMBOL_POISON;
EXPORT_SYMBOL(next_online_pgdat_fn);
#endif /* HAVE_NEXT_ONLINE_PGDAT */
#ifndef HAVE_NEXT_ZONE
-next_zone_t next_zone_fn = NULL;
+next_zone_t next_zone_fn = SYMBOL_POISON;
EXPORT_SYMBOL(next_zone_fn);
#endif /* HAVE_NEXT_ZONE */
#ifndef HAVE_ZONE_STAT_ITEM_FIA
# ifndef HAVE_GET_ZONE_COUNTS
-get_zone_counts_t get_zone_counts_fn = NULL;
+get_zone_counts_t get_zone_counts_fn = SYMBOL_POISON;
EXPORT_SYMBOL(get_zone_counts_fn);
+# endif /* HAVE_GET_ZONE_COUNTS */
unsigned long
spl_global_page_state(int item)
@@ -126,12 +127,13 @@ spl_global_page_state(int item)
return active;
}
+# ifdef HAVE_GLOBAL_PAGE_STATE
return global_page_state((enum zone_stat_item)item);
+# else
+ return 0; /* Unsupported */
+# endif /* HAVE_GLOBAL_PAGE_STATE */
}
EXPORT_SYMBOL(spl_global_page_state);
-# else
-# error "HAVE_ZONE_STAT_ITEM_FIA and HAVE_GET_ZONE_COUNTS unavailable"
-# endif /* HAVE_GET_ZONE_COUNTS */
#endif /* HAVE_ZONE_STAT_ITEM_FIA */
pgcnt_t
@@ -1785,8 +1787,8 @@ spl_kmem_init_globals(void)
}
/* Solaris default values */
- swapfs_minfree = MAX(2*1024*1024 / PAGE_SIZE, physmem / 8);
- swapfs_reserve = MIN(4*1024*1024 / PAGE_SIZE, physmem / 16);
+ swapfs_minfree = MAX(2*1024*1024 >> PAGE_SHIFT, physmem >> 3);
+ swapfs_reserve = MIN(4*1024*1024 >> PAGE_SHIFT, physmem >> 4);
}
/*
@@ -1839,8 +1841,6 @@ spl_kmem_init_kallsyms_lookup(void)
printk(KERN_ERR "Error: Unknown symbol get_zone_counts\n");
return -EFAULT;
}
-# else
-# error "HAVE_ZONE_STAT_ITEM_FIA and HAVE_GET_ZONE_COUNTS unavailable"
# endif /* HAVE_GET_ZONE_COUNTS */
#endif /* HAVE_ZONE_STAT_ITEM_FIA */
diff --git a/module/spl/spl-proc.c b/module/spl/spl-proc.c
index 294948d81..5dd7884f6 100644
--- a/module/spl/spl-proc.c
+++ b/module/spl/spl-proc.c
@@ -503,7 +503,7 @@ proc_dokallsyms_lookup_name(struct ctl_table *table, int write,
if (write) {
/* This may only be set once at module load time */
- if (spl_kallsyms_lookup_name_fn)
+ if (spl_kallsyms_lookup_name_fn != SYMBOL_POISON)
RETURN(-EEXIST);
/* We can't use proc_doulongvec_minmax() in the write
diff --git a/module/spl/spl-time.c b/module/spl/spl-time.c
index 88722afe1..1e9671e83 100644
--- a/module/spl/spl-time.c
+++ b/module/spl/spl-time.c
@@ -60,9 +60,9 @@ __gethrtime(void) {
/* Deal with signed/unsigned mismatch */
return (hrtime_t)(res & ~(1ULL << 63));
#else
- int64_t j = get_jiffies_64();
+ uint64_t j = get_jiffies_64();
- return j * NSEC_PER_SEC / HZ;
+ return (hrtime_t)(j * NSEC_PER_SEC / HZ);
#endif
}
EXPORT_SYMBOL(__gethrtime);