Skip to content

Commit

Permalink
Add linux kernel module support
Browse files Browse the repository at this point in the history
Setup linux kernel module support, this includes:
- zfs context for kernel/user
- kernel module build system integration
- kernel module macros
- kernel module symbol export
- kernel module options

Signed-off-by: Brian Behlendorf <[email protected]>
  • Loading branch information
behlendorf committed Aug 31, 2010
1 parent 00b4602 commit c28b227
Show file tree
Hide file tree
Showing 40 changed files with 820 additions and 10 deletions.
27 changes: 27 additions & 0 deletions module/avl/avl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,3 +1028,30 @@ avl_destroy_nodes(avl_tree_t *tree, void **cookie)

return (AVL_NODE2DATA(node, off));
}

#if defined(_KERNEL) && defined(HAVE_SPL)

static int avl_init(void) { return 0; }
static int avl_fini(void) { return 0; }

spl_module_init(avl_init);
spl_module_exit(avl_fini);

MODULE_DESCRIPTION("Generic AVL tree implementation");
MODULE_AUTHOR(ZFS_META_AUTHOR);
MODULE_LICENSE(ZFS_META_LICENSE);

EXPORT_SYMBOL(avl_create);
EXPORT_SYMBOL(avl_find);
EXPORT_SYMBOL(avl_insert);
EXPORT_SYMBOL(avl_insert_here);
EXPORT_SYMBOL(avl_walk);
EXPORT_SYMBOL(avl_first);
EXPORT_SYMBOL(avl_last);
EXPORT_SYMBOL(avl_nearest);
EXPORT_SYMBOL(avl_add);
EXPORT_SYMBOL(avl_remove);
EXPORT_SYMBOL(avl_numnodes);
EXPORT_SYMBOL(avl_destroy_nodes);
EXPORT_SYMBOL(avl_destroy);
#endif
128 changes: 128 additions & 0 deletions module/nvpair/nvpair.c
Original file line number Diff line number Diff line change
Expand Up @@ -3295,3 +3295,131 @@ nvs_xdr(nvstream_t *nvs, nvlist_t *nvl, char *buf, size_t *buflen)

return (err);
}

#if defined(_KERNEL) && defined(HAVE_SPL)

static int nvpair_init(void) { return 0; }
static int nvpair_fini(void) { return 0; }

spl_module_init(nvpair_init);
spl_module_exit(nvpair_fini);

MODULE_DESCRIPTION("Generic name/value pair implementation");
MODULE_AUTHOR(ZFS_META_AUTHOR);
MODULE_LICENSE(ZFS_META_LICENSE);

EXPORT_SYMBOL(nv_alloc_init);
EXPORT_SYMBOL(nv_alloc_reset);
EXPORT_SYMBOL(nv_alloc_fini);

/* list management */
EXPORT_SYMBOL(nvlist_alloc);
EXPORT_SYMBOL(nvlist_free);
EXPORT_SYMBOL(nvlist_size);
EXPORT_SYMBOL(nvlist_pack);
EXPORT_SYMBOL(nvlist_unpack);
EXPORT_SYMBOL(nvlist_dup);
EXPORT_SYMBOL(nvlist_merge);

EXPORT_SYMBOL(nvlist_xalloc);
EXPORT_SYMBOL(nvlist_xpack);
EXPORT_SYMBOL(nvlist_xunpack);
EXPORT_SYMBOL(nvlist_xdup);
EXPORT_SYMBOL(nvlist_lookup_nv_alloc);

EXPORT_SYMBOL(nvlist_add_nvpair);
EXPORT_SYMBOL(nvlist_add_boolean);
EXPORT_SYMBOL(nvlist_add_boolean_value);
EXPORT_SYMBOL(nvlist_add_byte);
EXPORT_SYMBOL(nvlist_add_int8);
EXPORT_SYMBOL(nvlist_add_uint8);
EXPORT_SYMBOL(nvlist_add_int16);
EXPORT_SYMBOL(nvlist_add_uint16);
EXPORT_SYMBOL(nvlist_add_int32);
EXPORT_SYMBOL(nvlist_add_uint32);
EXPORT_SYMBOL(nvlist_add_int64);
EXPORT_SYMBOL(nvlist_add_uint64);
EXPORT_SYMBOL(nvlist_add_string);
EXPORT_SYMBOL(nvlist_add_nvlist);
EXPORT_SYMBOL(nvlist_add_boolean_array);
EXPORT_SYMBOL(nvlist_add_byte_array);
EXPORT_SYMBOL(nvlist_add_int8_array);
EXPORT_SYMBOL(nvlist_add_uint8_array);
EXPORT_SYMBOL(nvlist_add_int16_array);
EXPORT_SYMBOL(nvlist_add_uint16_array);
EXPORT_SYMBOL(nvlist_add_int32_array);
EXPORT_SYMBOL(nvlist_add_uint32_array);
EXPORT_SYMBOL(nvlist_add_int64_array);
EXPORT_SYMBOL(nvlist_add_uint64_array);
EXPORT_SYMBOL(nvlist_add_string_array);
EXPORT_SYMBOL(nvlist_add_nvlist_array);
EXPORT_SYMBOL(nvlist_next_nvpair);
EXPORT_SYMBOL(nvlist_prev_nvpair);
EXPORT_SYMBOL(nvlist_empty);
EXPORT_SYMBOL(nvlist_add_hrtime);

EXPORT_SYMBOL(nvlist_remove);
EXPORT_SYMBOL(nvlist_remove_nvpair);
EXPORT_SYMBOL(nvlist_remove_all);

EXPORT_SYMBOL(nvlist_lookup_boolean);
EXPORT_SYMBOL(nvlist_lookup_boolean_value);
EXPORT_SYMBOL(nvlist_lookup_byte);
EXPORT_SYMBOL(nvlist_lookup_int8);
EXPORT_SYMBOL(nvlist_lookup_uint8);
EXPORT_SYMBOL(nvlist_lookup_int16);
EXPORT_SYMBOL(nvlist_lookup_uint16);
EXPORT_SYMBOL(nvlist_lookup_int32);
EXPORT_SYMBOL(nvlist_lookup_uint32);
EXPORT_SYMBOL(nvlist_lookup_int64);
EXPORT_SYMBOL(nvlist_lookup_uint64);
EXPORT_SYMBOL(nvlist_lookup_string);
EXPORT_SYMBOL(nvlist_lookup_nvlist);
EXPORT_SYMBOL(nvlist_lookup_boolean_array);
EXPORT_SYMBOL(nvlist_lookup_byte_array);
EXPORT_SYMBOL(nvlist_lookup_int8_array);
EXPORT_SYMBOL(nvlist_lookup_uint8_array);
EXPORT_SYMBOL(nvlist_lookup_int16_array);
EXPORT_SYMBOL(nvlist_lookup_uint16_array);
EXPORT_SYMBOL(nvlist_lookup_int32_array);
EXPORT_SYMBOL(nvlist_lookup_uint32_array);
EXPORT_SYMBOL(nvlist_lookup_int64_array);
EXPORT_SYMBOL(nvlist_lookup_uint64_array);
EXPORT_SYMBOL(nvlist_lookup_string_array);
EXPORT_SYMBOL(nvlist_lookup_nvlist_array);
EXPORT_SYMBOL(nvlist_lookup_hrtime);
EXPORT_SYMBOL(nvlist_lookup_pairs);

EXPORT_SYMBOL(nvlist_lookup_nvpair);
EXPORT_SYMBOL(nvlist_exists);

/* processing nvpair */
EXPORT_SYMBOL(nvpair_name);
EXPORT_SYMBOL(nvpair_type);
EXPORT_SYMBOL(nvpair_value_boolean_value);
EXPORT_SYMBOL(nvpair_value_byte);
EXPORT_SYMBOL(nvpair_value_int8);
EXPORT_SYMBOL(nvpair_value_uint8);
EXPORT_SYMBOL(nvpair_value_int16);
EXPORT_SYMBOL(nvpair_value_uint16);
EXPORT_SYMBOL(nvpair_value_int32);
EXPORT_SYMBOL(nvpair_value_uint32);
EXPORT_SYMBOL(nvpair_value_int64);
EXPORT_SYMBOL(nvpair_value_uint64);
EXPORT_SYMBOL(nvpair_value_string);
EXPORT_SYMBOL(nvpair_value_nvlist);
EXPORT_SYMBOL(nvpair_value_boolean_array);
EXPORT_SYMBOL(nvpair_value_byte_array);
EXPORT_SYMBOL(nvpair_value_int8_array);
EXPORT_SYMBOL(nvpair_value_uint8_array);
EXPORT_SYMBOL(nvpair_value_int16_array);
EXPORT_SYMBOL(nvpair_value_uint16_array);
EXPORT_SYMBOL(nvpair_value_int32_array);
EXPORT_SYMBOL(nvpair_value_uint32_array);
EXPORT_SYMBOL(nvpair_value_int64_array);
EXPORT_SYMBOL(nvpair_value_uint64_array);
EXPORT_SYMBOL(nvpair_value_string_array);
EXPORT_SYMBOL(nvpair_value_nvlist_array);
EXPORT_SYMBOL(nvpair_value_hrtime);

#endif
4 changes: 4 additions & 0 deletions module/nvpair/nvpair_alloc_fixed.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,7 @@ const nv_alloc_ops_t nv_fixed_ops_def = {
};

const nv_alloc_ops_t *nv_fixed_ops = &nv_fixed_ops_def;

#if defined(_KERNEL) && defined(HAVE_SPL)
EXPORT_SYMBOL(nv_fixed_ops);
#endif
75 changes: 75 additions & 0 deletions module/nvpair/nvpair_alloc_spl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at * usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/

#include <sys/nvpair.h>
#include <sys/kmem.h>

static void *
nv_alloc_sleep_spl(nv_alloc_t *nva, size_t size)
{
return (kmem_alloc(size, KM_SLEEP));
}

static void *
nv_alloc_nosleep_spl(nv_alloc_t *nva, size_t size)
{
return (kmem_alloc(size, KM_NOSLEEP));
}

static void
nv_free_spl(nv_alloc_t *nva, void *buf, size_t size)
{
kmem_free(buf, size);
}

const nv_alloc_ops_t spl_sleep_ops_def = {
NULL, /* nv_ao_init() */
NULL, /* nv_ao_fini() */
nv_alloc_sleep_spl, /* nv_ao_alloc() */
nv_free_spl, /* nv_ao_free() */
NULL /* nv_ao_reset() */
};

const nv_alloc_ops_t spl_nosleep_ops_def = {
NULL, /* nv_ao_init() */
NULL, /* nv_ao_fini() */
nv_alloc_nosleep_spl, /* nv_ao_alloc() */
nv_free_spl, /* nv_ao_free() */
NULL /* nv_ao_reset() */
};

nv_alloc_t nv_alloc_sleep_def = {
&spl_sleep_ops_def,
NULL
};

nv_alloc_t nv_alloc_nosleep_def = {
&spl_nosleep_ops_def,
NULL
};

nv_alloc_t *nv_alloc_sleep = &nv_alloc_sleep_def;
nv_alloc_t *nv_alloc_nosleep = &nv_alloc_nosleep_def;
17 changes: 17 additions & 0 deletions module/unicode/u8_textprep.c
Original file line number Diff line number Diff line change
Expand Up @@ -2131,3 +2131,20 @@ u8_textprep_str(char *inarray, size_t *inlen, char *outarray, size_t *outlen,

return (ret_val);
}

#if defined(_KERNEL) && defined(HAVE_SPL)

static int unicode_init(void) { return 0; }
static int unicode_fini(void) { return 0; }

spl_module_init(unicode_init);
spl_module_exit(unicode_fini);

MODULE_DESCRIPTION("Unicode implementation");
MODULE_AUTHOR(ZFS_META_AUTHOR);
MODULE_LICENSE(ZFS_META_LICENSE);

EXPORT_SYMBOL(u8_validate);
EXPORT_SYMBOL(u8_strcmp);
EXPORT_SYMBOL(u8_textprep_str);
#endif
9 changes: 9 additions & 0 deletions module/unicode/uconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,3 +853,12 @@ uconv_u8tou32(const uchar_t *u8s, size_t *utf8len,

return (0);
}

#if defined(_KERNEL) && defined(HAVE_SPL)
EXPORT_SYMBOL(uconv_u16tou32);
EXPORT_SYMBOL(uconv_u16tou8);
EXPORT_SYMBOL(uconv_u32tou16);
EXPORT_SYMBOL(uconv_u32tou8);
EXPORT_SYMBOL(uconv_u8tou16);
EXPORT_SYMBOL(uconv_u8tou32);
#endif
8 changes: 8 additions & 0 deletions module/zcommon/zfs_comutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,11 @@ const char *zfs_history_event_names[LOG_END] = {
"user release",
"pool split",
};

#if defined(_KERNEL) && defined(HAVE_SPL)
EXPORT_SYMBOL(zfs_allocatable_devs);
EXPORT_SYMBOL(zpool_get_rewind_policy);
EXPORT_SYMBOL(zfs_zpl_version_map);
EXPORT_SYMBOL(zfs_spa_version_map);
EXPORT_SYMBOL(zfs_history_event_names);
#endif
6 changes: 6 additions & 0 deletions module/zcommon/zfs_deleg.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,9 @@ zfs_deleg_whokey(char *attr, zfs_deleg_who_type_t type,
ASSERT(!"bad zfs_deleg_who_type_t");
}
}

#if defined(_KERNEL) && defined(HAVE_SPL)
EXPORT_SYMBOL(zfs_deleg_verify_nvlist);
EXPORT_SYMBOL(zfs_deleg_whokey);
EXPORT_SYMBOL(zfs_deleg_canonicalize_perm);
#endif
9 changes: 9 additions & 0 deletions module/zcommon/zfs_fletcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,12 @@ fletcher_4_incremental_byteswap(const void *buf, uint64_t size,

ZIO_SET_CHECKSUM(zcp, a, b, c, d);
}

#if defined(_KERNEL) && defined(HAVE_SPL)
EXPORT_SYMBOL(fletcher_2_native);
EXPORT_SYMBOL(fletcher_2_byteswap);
EXPORT_SYMBOL(fletcher_4_native);
EXPORT_SYMBOL(fletcher_4_byteswap);
EXPORT_SYMBOL(fletcher_4_incremental_native);
EXPORT_SYMBOL(fletcher_4_incremental_byteswap);
#endif
6 changes: 6 additions & 0 deletions module/zcommon/zfs_namecheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,9 @@ pool_namecheck(const char *pool, namecheck_err_t *why, char *what)

return (0);
}

#if defined(_KERNEL) && defined(HAVE_SPL)
EXPORT_SYMBOL(snapshot_namecheck);
EXPORT_SYMBOL(pool_namecheck);
EXPORT_SYMBOL(dataset_namecheck);
#endif
35 changes: 35 additions & 0 deletions module/zcommon/zfs_prop.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,3 +593,38 @@ zfs_prop_align_right(zfs_prop_t prop)
}

#endif

#if defined(_KERNEL) && defined(HAVE_SPL)

static int zcommon_init(void) { return 0; }
static int zcommon_fini(void) { return 0; }

spl_module_init(zcommon_init);
spl_module_exit(zcommon_fini);

MODULE_DESCRIPTION("Generic ZFS support");
MODULE_AUTHOR(ZFS_META_AUTHOR);
MODULE_LICENSE(ZFS_META_LICENSE);

/* zfs dataset property functions */
EXPORT_SYMBOL(zfs_userquota_prop_prefixes);
EXPORT_SYMBOL(zfs_prop_init);
EXPORT_SYMBOL(zfs_prop_get_type);
EXPORT_SYMBOL(zfs_prop_get_table);
EXPORT_SYMBOL(zfs_prop_delegatable);

/* Dataset property functions shared between libzfs and kernel. */
EXPORT_SYMBOL(zfs_prop_default_string);
EXPORT_SYMBOL(zfs_prop_default_numeric);
EXPORT_SYMBOL(zfs_prop_readonly);
EXPORT_SYMBOL(zfs_prop_inheritable);
EXPORT_SYMBOL(zfs_prop_setonce);
EXPORT_SYMBOL(zfs_prop_to_name);
EXPORT_SYMBOL(zfs_name_to_prop);
EXPORT_SYMBOL(zfs_prop_user);
EXPORT_SYMBOL(zfs_prop_userquota);
EXPORT_SYMBOL(zfs_prop_index_to_string);
EXPORT_SYMBOL(zfs_prop_string_to_index);
EXPORT_SYMBOL(zfs_prop_valid_for_type);

#endif
16 changes: 16 additions & 0 deletions module/zcommon/zpool_prop.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,19 @@ zpool_prop_align_right(zpool_prop_t prop)
return (zpool_prop_table[prop].pd_rightalign);
}
#endif

#if defined(_KERNEL) && defined(HAVE_SPL)
/* zpool property functions */
EXPORT_SYMBOL(zpool_prop_init);
EXPORT_SYMBOL(zpool_prop_get_type);
EXPORT_SYMBOL(zpool_prop_get_table);

/* Pool property functions shared between libzfs and kernel. */
EXPORT_SYMBOL(zpool_name_to_prop);
EXPORT_SYMBOL(zpool_prop_to_name);
EXPORT_SYMBOL(zpool_prop_default_string);
EXPORT_SYMBOL(zpool_prop_default_numeric);
EXPORT_SYMBOL(zpool_prop_readonly);
EXPORT_SYMBOL(zpool_prop_index_to_string);
EXPORT_SYMBOL(zpool_prop_string_to_index);
#endif
Loading

0 comments on commit c28b227

Please sign in to comment.