mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Linux VM Integration Cleanup
Remove all instances of functions being reimplemented in the SPL. When the prototypes are available in the linux headers but the function address itself is not exported use kallsyms_lookup_name() to find the address. The function name itself can them become a define which calls a function pointer. This is preferable to reimplementing the function in the SPL because it ensures we get the correct version of the function for the running kernel. This is actually pretty safe because the prototype is defined in the headers so we know we are calling the function properly. This patch also includes a rhel5 kernel patch we exports the needed symbols so we don't need to use kallsyms_lookup_name(). There are autoconf checks to detect if the symbol is exported and if so to use it directly. We should add patches for stock upstream kernels as needed if for no other reason than so we can easily track which additional symbols we needed exported. Those patches can also be used by anyone willing to rebuild their kernel, but this should not be a requirement. The rhel5 version of the export-symbols patch has been applied to the chaos kernel. Additional fixes: 1) Implement vmem_size() function using get_vmalloc_info() 2) SPL_CHECK_SYMBOL_EXPORT macro updated to use $LINUX_OBJ instead of $LINUX because Module.symvers is a build product. When $LINUX_OBJ != $LINUX we will not properly detect exported symbols. 3) SPL_LINUX_COMPILE_IFELSE macro updated to add include2 and $LINUX/include search paths to allow proper compilation when the kernel target build directory is not the source directory.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#ifndef _SPL_KALLSYMS_COMPAT_H
|
||||
#define _SPL_KALLSYMS_COMPAT_H
|
||||
|
||||
#ifdef HAVE_KALLSYMS_LOOKUP_NAME
|
||||
|
||||
#include <linux/kallsyms.h>
|
||||
#define spl_kallsyms_lookup_name(name) kallsyms_lookup_name(name)
|
||||
|
||||
#else
|
||||
|
||||
typedef unsigned long (*kallsyms_lookup_name_t)(const char *);
|
||||
extern kallsyms_lookup_name_t spl_kallsyms_lookup_name_fn;
|
||||
#define spl_kallsyms_lookup_name(name) spl_kallsyms_lookup_name_fn(name)
|
||||
|
||||
#endif /* HAVE_KALLSYMS_LOOKUP_NAME */
|
||||
|
||||
#endif /* _SPL_KALLSYMS_COMPAT_H */
|
||||
@@ -325,6 +325,7 @@ extern void spl_kmem_cache_free(spl_kmem_cache_t *skc, void *obj);
|
||||
extern void spl_kmem_cache_reap_now(spl_kmem_cache_t *skc);
|
||||
extern void spl_kmem_reap(void);
|
||||
|
||||
int spl_kmem_init_kallsyms_lookup(void);
|
||||
int spl_kmem_init(void);
|
||||
void spl_kmem_fini(void);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ extern "C" {
|
||||
#include <linux/bitops_compat.h>
|
||||
#include <linux/smp_compat.h>
|
||||
#include <linux/workqueue_compat.h>
|
||||
#include <linux/kallsyms_compat.h>
|
||||
|
||||
#ifndef HAVE_UINTPTR_T
|
||||
typedef unsigned long uintptr_t;
|
||||
|
||||
+62
-3
@@ -58,12 +58,71 @@ extern vmem_t *heap_arena; /* primary kernel heap arena */
|
||||
extern vmem_t *zio_alloc_arena; /* arena for zio caches */
|
||||
extern vmem_t *zio_arena; /* arena for allocating zio memory */
|
||||
|
||||
#define VMEM_ALLOC 0x01
|
||||
#define VMEM_FREE 0x02
|
||||
|
||||
extern pgcnt_t spl_kmem_availrmem(void);
|
||||
extern size_t vmem_size(vmem_t *vmp, int typemask);
|
||||
|
||||
/*
|
||||
* The following symbols are available for use within the kernel
|
||||
* itself, and they used to be available in older kernels. But it
|
||||
* looks like they have been removed perhaps due to lack of use.
|
||||
* For our purposes we need them to access the global memory state
|
||||
* of the system, which is even available to user space process
|
||||
* in /proc/meminfo. It's odd to me that there is no kernel API
|
||||
* to get the same information, minimally the proc handler for
|
||||
* the above mentioned /proc/meminfo file would make use of it.
|
||||
*/
|
||||
|
||||
/* Source linux/fs/proc/mmu.c */
|
||||
#ifndef HAVE_GET_VMALLOC_INFO
|
||||
#ifdef CONFIG_MMU
|
||||
|
||||
struct vmalloc_info {
|
||||
unsigned long used;
|
||||
unsigned long largest_chunk;
|
||||
};
|
||||
|
||||
typedef void (*get_vmalloc_info_t)(struct vmalloc_info *);
|
||||
extern get_vmalloc_info_t get_vmalloc_info_fn;
|
||||
|
||||
# define VMEM_ALLOC 0x01
|
||||
# define VMEM_FREE 0x02
|
||||
# define VMALLOC_TOTAL (VMALLOC_END - VMALLOC_START)
|
||||
# define get_vmalloc_info(vmi) get_vmalloc_info_fn(vmi)
|
||||
#else
|
||||
# error "CONFIG_MMU must be defined"
|
||||
#endif /* CONFIG_MMU */
|
||||
#endif /* HAVE_GET_VMALLOC_INFO */
|
||||
|
||||
/* Source linux/mm/mmzone.c */
|
||||
#ifndef HAVE_FIRST_ONLINE_PGDAT
|
||||
typedef struct pglist_data *(*first_online_pgdat_t)(void);
|
||||
extern first_online_pgdat_t first_online_pgdat_fn;
|
||||
#define first_online_pgdat() first_online_pgdat_fn()
|
||||
#endif /* HAVE_FIRST_ONLINE_PGDAT */
|
||||
|
||||
/* Source linux/mm/mmzone.c */
|
||||
#ifndef HAVE_NEXT_ONLINE_PGDAT
|
||||
typedef struct pglist_data *(*next_online_pgdat_t)(struct pglist_data *);
|
||||
extern next_online_pgdat_t next_online_pgdat_fn;
|
||||
#define next_online_pgdat(pgd) next_online_pgdat_fn(pgd)
|
||||
#endif /* HAVE_NEXT_ONLINE_PGDAT */
|
||||
|
||||
/* Source linux/mm/mmzone.c */
|
||||
#ifndef HAVE_NEXT_ZONE
|
||||
typedef struct zone *(*next_zone_t)(struct zone *);
|
||||
extern next_zone_t next_zone_fn;
|
||||
#define next_zone(zone) next_zone_fn(zone)
|
||||
#endif /* HAVE_NEXT_ZONE */
|
||||
|
||||
/* Source linux/mm/vmstat.c */
|
||||
#ifndef HAVE_GET_ZONE_COUNTS
|
||||
typedef void (*get_zone_counts_t)(unsigned long *, unsigned long *,
|
||||
unsigned long *);
|
||||
extern get_zone_counts_t get_zone_counts_fn;
|
||||
#define get_zone_counts(a,i,f) get_zone_counts_fn(a,i,f)
|
||||
#endif /* HAVE_GET_ZONE_COUNTS */
|
||||
|
||||
|
||||
#define xcopyin(from, to, size) copy_from_user(to, from, size)
|
||||
#define xcopyout(from, to, size) copy_to_user(to, from, size)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user