Prepare SPL repo to merge with ZFS repo

This commit removes everything from the repository except the core
SPL implementation for Linux.  Those files which remain have been
moved to non-conflicting locations to facilitate the merge.
The README.md and associated files have been updated accordingly.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
Brian Behlendorf 2018-02-14 17:01:15 -08:00
parent 1149b62d20
commit a91258913f
222 changed files with 777 additions and 16870 deletions

52
.gitignore vendored
View File

@ -1,52 +0,0 @@
#
# N.B.
# This is the toplevel .gitignore file.
# This is not the place for entries that are specific to
# a subdirectory. Instead add those files to the
# .gitignore file in that subdirectory.
#
# N.B.
# Please use 'git ls-files -i --exclude-standard'
# command after changing this file, to see if there are
# any tracked files which get ignored after the change.
#
# Normal rules
#
*.[oad]
*.lo
*.la
*~
*.swp
.deps
.libs
.DS_Store
Makefile
Makefile.in
#
# Top level generated files specific to this top level dir
#
/configure
/config.log
/config.status
/libtool
/spl_config.h
/spl_config.h.in
/spl.release
/stamp-h1
/aclocal.m4
/autom4te.cache
#
# Top level generic files
#
!.gitignore
tags
TAGS
cscope.*
*.rpm
*.deb
*.tar.gz
*.patch
*.orig

View File

@ -1,24 +0,0 @@
This work was produced at the Lawrence Livermore National Laboratory
(LLNL) under Contract No. DE-AC52-07NA27344 (Contract 44) between
the U.S. Department of Energy (DOE) and Lawrence Livermore National
Security, LLC (LLNS) for the operation of LLNL.
This work was prepared as an account of work sponsored by an agency of
the United States Government. Neither the United States Government nor
Lawrence Livermore National Security, LLC nor any of their employees,
makes any warranty, express or implied, or assumes any liability or
responsibility for the accuracy, completeness, or usefulness of any
information, apparatus, product, or process disclosed, or represents
that its use would not infringe privately-owned rights.
Reference herein to any specific commercial products, process, or
services by trade name, trademark, manufacturer or otherwise does
not necessarily constitute or imply its endorsement, recommendation,
or favoring by the United States Government or Lawrence Livermore
National Security, LLC. The views and opinions of authors expressed
herein do not necessarily state or reflect those of the Untied States
Government or Lawrence Livermore National Security, LLC, and shall
not be used for advertising or product endorsement purposes.
The precise terms and conditions for copying, distribution, and
modification are specified in the file "COPYING".

View File

8
META
View File

@ -1,8 +0,0 @@
Meta: 1
Name: spl
Branch: 1.0
Version: 0.7.0
Release: 1
Release-Tags: relext
License: GPL
Author: OpenZFS on Linux

View File

@ -1,55 +0,0 @@
ACLOCAL_AMFLAGS = -I config
include config/rpm.am
include config/deb.am
include config/tgz.am
SUBDIRS = include rpm
if CONFIG_USER
SUBDIRS += lib cmd man scripts
endif
if CONFIG_KERNEL
SUBDIRS += module
extradir = @prefix@/src/spl-$(VERSION)
extra_HEADERS = spl.release.in spl_config.h.in
kerneldir = @prefix@/src/spl-$(VERSION)/$(LINUX_VERSION)
nodist_kernel_HEADERS = spl.release spl_config.h module/$(LINUX_SYMBOLS)
endif
AUTOMAKE_OPTIONS = foreign
EXTRA_DIST = autogen.sh META DISCLAIMER copy-builtin
EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am
distclean-local::
-$(RM) -R autom4te*.cache
-find . \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \
-o -name .pc -o -name .hg -o -name .git \) -prune -o \
\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
-o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
-o -name '.*.rej' -o -name 'aclocal.m4' -o -size 0 \
-o -name '*%' -o -name '.*.cmd' -o -name 'core' \
-o -name 'Makefile' -o -name '$(LINUX_SYMBOLS)' \
-o -name '*.order' -o -name '*.markers' \) \
-type f -print | xargs $(RM)
dist-hook:
sed -i 's/Release:[[:print:]]*/Release: $(RELEASE)/' \
$(distdir)/META
ctags:
$(RM) tags
find $(top_srcdir) -name .git -prune -o -name '*.[hc]' | xargs ctags
etags:
$(RM) TAGS
find $(top_srcdir) -name .pc -prune -o -name '*.[hc]' | xargs etags -a
tags: ctags etags
pkg: @DEFAULT_PACKAGE@
pkg-dkms: @DEFAULT_PACKAGE@-dkms
pkg-kmod: @DEFAULT_PACKAGE@-kmod
pkg-utils: @DEFAULT_PACKAGE@-utils

16
NOTICE Normal file
View File

@ -0,0 +1,16 @@
This work was produced under the auspices of the U.S. Department of Energy by
Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.
This work was prepared as an account of work sponsored by an agency of the
United States Government. Neither the United States Government nor Lawrence
Livermore National Security, LLC, nor any of their employees makes any warranty,
expressed or implied, or assumes any legal liability or responsibility for the
accuracy, completeness, or usefulness of any information, apparatus, product, or
process disclosed, or represents that its use would not infringe privately owned
rights. Reference herein to any specific commercial product, process, or service
by trade name, trademark, manufacturer, or otherwise does not necessarily
constitute or imply its endorsement, recommendation, or favoring by the United
States Government or Lawrence Livermore National Security, LLC. The views and
opinions of authors expressed herein do not necessarily state or reflect those
of the United States Government or Lawrence Livermore National Security, LLC,
and shall not be used for advertising or product endorsement purposes.

View File

@ -1,36 +0,0 @@
The Solaris Porting Layer (SPL) is a Linux kernel module which provides
many of the Solaris kernel APIs. This shim layer makes it possible to
run Solaris kernel code in the Linux kernel with relatively minimal
modification. This can be particularly useful when you want to track
upstream Solaris development closely and do not want the overhead of
maintaining a large patch which converts Solaris primitives to Linux
primitives.
To build packages for your distribution:
$ sh autogen.sh
$ ./configure
$ make pkg
If you are building directly from the git tree and not an officially
released tarball you will need to generate the configure script.
This can be done by executing the autogen.sh script after installing
the GNU autotools for your distribution.
To copy the kernel code inside your kernel source tree for builtin
compilation:
$ sh autogen.sh
$ ./configure --enable-linux-builtin --with-linux=/usr/src/linux-...
$ ./copy-builtin /usr/src/linux-...
The SPL comes with an automated test suite called SPLAT. The test suite
is implemented in two parts. There is a kernel module which contains
the tests and a user space utility which controls which tests are run.
To run the full test suite:
$ sudo insmod ./module/splat/splat.ko
$ sudo ./cmd/splat --all
Full documentation for building, configuring, testing, and using the
SPL can be found at: <http://zfsonlinux.org>

21
README.md Normal file
View File

@ -0,0 +1,21 @@
![img](http://zfsonlinux.org/images/zfs-linux.png)
The Solaris Porting Layer, SPL, is a Linux kernel module which provides a
compatibility layer used by the [ZFS on Linux](http://zfsonlinux.org) project.
# Installation
The latest version of the SPL is maintained as part of the ZFS on Linux
Github repository:
* Latest Version: https://github.com/zfsonlinux/zfs
Cloning this repository is only needed when building version 0.7.x or earlier.
* Version 0.7.x: https://github.com/zfsonlinux/spl/tree/spl-0.7-release
* Version 0.6.5.x: https://github.com/zfsonlinux/spl/tree/spl-0.6.5-release
# Release
The SPL is released under a GPLv2 license. For more details see the NOTICE
and LICENSE files; `UCRL-CODE-235197`

View File

@ -1,4 +0,0 @@
#!/bin/sh
autoreconf -fiv
rm -Rf autom4te.cache

View File

@ -1 +0,0 @@
SUBDIRS = splat splslab

View File

@ -1 +0,0 @@
/splat

View File

@ -1,11 +0,0 @@
include $(top_srcdir)/config/Rules.am
DEFAULT_INCLUDES += \
-I$(top_srcdir)/lib
sbin_PROGRAMS = splat
splat_SOURCES = splat.c
splat_LDFLAGS = $(top_builddir)/lib/libcommon.la
EXTRA_DIST = splat.h

View File

@ -1,836 +0,0 @@
/*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
* Solaris Porting LAyer Tests (SPLAT) User Space Interface.
*/
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include <assert.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "splat.h"
#undef ioctl
static const char shortOpts[] = "hvlat:xc";
static const struct option longOpts[] = {
{ "help", no_argument, 0, 'h' },
{ "verbose", no_argument, 0, 'v' },
{ "list", no_argument, 0, 'l' },
{ "all", no_argument, 0, 'a' },
{ "test", required_argument, 0, 't' },
{ "exit", no_argument, 0, 'x' },
{ "nocolor", no_argument, 0, 'c' },
{ 0, 0, 0, 0 }
};
#define VERSION_SIZE 64
static List subsystems; /* Subsystem/tests */
static int splatctl_fd; /* Control file descriptor */
static char splat_version[VERSION_SIZE]; /* Kernel version string */
static char *splat_buffer = NULL; /* Scratch space area */
static int splat_buffer_size = 0; /* Scratch space size */
static void test_list(List, int);
static int dev_clear(void);
static void subsystem_fini(subsystem_t *);
static void test_fini(test_t *);
static int usage(void) {
fprintf(stderr, "usage: splat [hvla] [-t <subsystem:<tests>>]\n");
fprintf(stderr,
" --help -h This help\n"
" --verbose -v Increase verbosity\n"
" --list -l List all tests in all subsystems\n"
" --all -a Run all tests in all subsystems\n"
" --test -t <sub:test> Run 'test' in subsystem 'sub'\n"
" --exit -x Exit on first test error\n"
" --nocolor -c Do not colorize output\n");
fprintf(stderr, "\n"
"Examples:\n"
" splat -t kmem:all # Runs all kmem tests\n"
" splat -t taskq:0x201 # Run taskq test 0x201\n");
return 0;
}
static subsystem_t *subsystem_init(splat_user_t *desc)
{
subsystem_t *sub;
sub = (subsystem_t *)malloc(sizeof(*sub));
if (sub == NULL)
return NULL;
memcpy(&sub->sub_desc, desc, sizeof(*desc));
sub->sub_tests = list_create((ListDelF)test_fini);
if (sub->sub_tests == NULL) {
free(sub);
return NULL;
}
return sub;
}
static void subsystem_fini(subsystem_t *sub)
{
assert(sub != NULL);
free(sub);
}
static int subsystem_setup(void)
{
splat_cfg_t *cfg;
int i, rc, size, cfg_size;
subsystem_t *sub;
splat_user_t *desc;
/* Aquire the number of registered subsystems */
cfg_size = sizeof(*cfg);
cfg = (splat_cfg_t *)malloc(cfg_size);
if (cfg == NULL)
return -ENOMEM;
memset(cfg, 0, cfg_size);
cfg->cfg_magic = SPLAT_CFG_MAGIC;
cfg->cfg_cmd = SPLAT_CFG_SUBSYSTEM_COUNT;
rc = ioctl(splatctl_fd, SPLAT_CFG, cfg);
if (rc) {
fprintf(stderr, "Ioctl() error 0x%lx / %d: %d\n",
(unsigned long)SPLAT_CFG, cfg->cfg_cmd, errno);
free(cfg);
return rc;
}
size = cfg->cfg_rc1;
free(cfg);
/* Based on the newly acquired number of subsystems allocate
* memory to get the descriptive information for them all. */
cfg_size = sizeof(*cfg) + size * sizeof(splat_user_t);
cfg = (splat_cfg_t *)malloc(cfg_size);
if (cfg == NULL)
return -ENOMEM;
memset(cfg, 0, cfg_size);
cfg->cfg_magic = SPLAT_CFG_MAGIC;
cfg->cfg_cmd = SPLAT_CFG_SUBSYSTEM_LIST;
cfg->cfg_data.splat_subsystems.size = size;
rc = ioctl(splatctl_fd, SPLAT_CFG, cfg);
if (rc) {
fprintf(stderr, "Ioctl() error %lu / %d: %d\n",
(unsigned long) SPLAT_CFG, cfg->cfg_cmd, errno);
free(cfg);
return rc;
}
/* Add the new subsystems in to the global list */
size = cfg->cfg_rc1;
for (i = 0; i < size; i++) {
desc = &(cfg->cfg_data.splat_subsystems.descs[i]);
sub = subsystem_init(desc);
if (sub == NULL) {
fprintf(stderr, "Error initializing subsystem: %s\n",
desc->name);
free(cfg);
return -ENOMEM;
}
list_append(subsystems, sub);
}
free(cfg);
return 0;
}
static void subsystem_list(List l, int indent)
{
ListIterator i;
subsystem_t *sub;
fprintf(stdout,
"------------------------------ "
"Available SPLAT Tests "
"------------------------------\n");
i = list_iterator_create(l);
while ((sub = list_next(i))) {
fprintf(stdout, "%*s0x%0*x %-*s ---- %s ----\n",
indent, "",
4, sub->sub_desc.id,
SPLAT_NAME_SIZE + 7, sub->sub_desc.name,
sub->sub_desc.desc);
test_list(sub->sub_tests, indent + 7);
}
list_iterator_destroy(i);
}
static test_t *test_init(subsystem_t *sub, splat_user_t *desc)
{
test_t *test;
test = (test_t *)malloc(sizeof(*test));
if (test == NULL)
return NULL;
test->test_sub = sub;
memcpy(&test->test_desc, desc, sizeof(*desc));
return test;
}
static void test_fini(test_t *test)
{
assert(test != NULL);
free(test);
}
static int test_setup(subsystem_t *sub)
{
splat_cfg_t *cfg;
int i, rc, size;
test_t *test;
splat_user_t *desc;
/* Aquire the number of registered tests for the give subsystem */
cfg = (splat_cfg_t *)malloc(sizeof(*cfg));
if (cfg == NULL)
return -ENOMEM;
memset(cfg, 0, sizeof(*cfg));
cfg->cfg_magic = SPLAT_CFG_MAGIC;
cfg->cfg_cmd = SPLAT_CFG_TEST_COUNT;
cfg->cfg_arg1 = sub->sub_desc.id; /* Subsystem of interest */
rc = ioctl(splatctl_fd, SPLAT_CFG, cfg);
if (rc) {
fprintf(stderr, "Ioctl() error %lu / %d: %d\n",
(unsigned long) SPLAT_CFG, cfg->cfg_cmd, errno);
free(cfg);
return rc;
}
size = cfg->cfg_rc1;
free(cfg);
/* Based on the newly aquired number of tests allocate enough
* memory to get the descriptive information for them all. */
cfg = (splat_cfg_t *)malloc(sizeof(*cfg) + size*sizeof(splat_user_t));
if (cfg == NULL)
return -ENOMEM;
memset(cfg, 0, sizeof(*cfg) + size * sizeof(splat_user_t));
cfg->cfg_magic = SPLAT_CFG_MAGIC;
cfg->cfg_cmd = SPLAT_CFG_TEST_LIST;
cfg->cfg_arg1 = sub->sub_desc.id; /* Subsystem of interest */
cfg->cfg_data.splat_tests.size = size;
rc = ioctl(splatctl_fd, SPLAT_CFG, cfg);
if (rc) {
fprintf(stderr, "Ioctl() error %lu / %d: %d\n",
(unsigned long) SPLAT_CFG, cfg->cfg_cmd, errno);
free(cfg);
return rc;
}
/* Add the new tests in to the relevant subsystems */
size = cfg->cfg_rc1;
for (i = 0; i < size; i++) {
desc = &(cfg->cfg_data.splat_tests.descs[i]);
test = test_init(sub, desc);
if (test == NULL) {
fprintf(stderr, "Error initializing test: %s\n",
desc->name);
free(cfg);
return -ENOMEM;
}
list_append(sub->sub_tests, test);
}
free(cfg);
return 0;
}
static test_t *test_copy(test_t *test)
{
return test_init(test->test_sub, &test->test_desc);
}
static void test_list(List l, int indent)
{
ListIterator i;
test_t *test;
i = list_iterator_create(l);
while ((test = list_next(i)))
fprintf(stdout, "%*s0x%0*x %-*s %s\n",
indent, "", 04, test->test_desc.id,
SPLAT_NAME_SIZE, test->test_desc.name,
test->test_desc.desc);
list_iterator_destroy(i);
}
static test_t *test_find(char *sub_str, char *test_str)
{
ListIterator si, ti;
subsystem_t *sub;
test_t *test;
__u32 sub_num, test_num;
/*
* No error checking here because it may not be a number, it's
* perfectly OK for it to be a string. Since we're just using
* it for comparison purposes this is all very safe.
*/
sub_num = strtoul(sub_str, NULL, 0);
test_num = strtoul(test_str, NULL, 0);
si = list_iterator_create(subsystems);
while ((sub = list_next(si))) {
if (strncmp(sub->sub_desc.name, sub_str, SPLAT_NAME_SIZE) &&
sub->sub_desc.id != sub_num)
continue;
ti = list_iterator_create(sub->sub_tests);
while ((test = list_next(ti))) {
if (!strncmp(test->test_desc.name, test_str,
SPLAT_NAME_SIZE) || test->test_desc.id==test_num) {
list_iterator_destroy(ti);
list_iterator_destroy(si);
return test;
}
}
list_iterator_destroy(ti);
}
list_iterator_destroy(si);
return NULL;
}
static int test_add(cmd_args_t *args, test_t *test)
{
test_t *tmp;
tmp = test_copy(test);
if (tmp == NULL)
return -ENOMEM;
list_append(args->args_tests, tmp);
return 0;
}
static int test_add_all(cmd_args_t *args)
{
ListIterator si, ti;
subsystem_t *sub;
test_t *test;
int rc;
si = list_iterator_create(subsystems);
while ((sub = list_next(si))) {
ti = list_iterator_create(sub->sub_tests);
while ((test = list_next(ti))) {
if ((rc = test_add(args, test))) {
list_iterator_destroy(ti);
list_iterator_destroy(si);
return rc;
}
}
list_iterator_destroy(ti);
}
list_iterator_destroy(si);
return 0;
}
static int test_run(cmd_args_t *args, test_t *test)
{
subsystem_t *sub = test->test_sub;
splat_cmd_t *cmd;
int rc, cmd_size;
dev_clear();
cmd_size = sizeof(*cmd);
cmd = (splat_cmd_t *)malloc(cmd_size);
if (cmd == NULL)
return -ENOMEM;
memset(cmd, 0, cmd_size);
cmd->cmd_magic = SPLAT_CMD_MAGIC;
cmd->cmd_subsystem = sub->sub_desc.id;
cmd->cmd_test = test->test_desc.id;
cmd->cmd_data_size = 0; /* Unused feature */
fprintf(stdout, "%*s:%-*s ",
SPLAT_NAME_SIZE, sub->sub_desc.name,
SPLAT_NAME_SIZE, test->test_desc.name);
fflush(stdout);
rc = ioctl(splatctl_fd, SPLAT_CMD, cmd);
if (args->args_do_color) {
fprintf(stdout, "%s %s\n", rc ?
COLOR_RED "Fail" COLOR_RESET :
COLOR_GREEN "Pass" COLOR_RESET,
rc ? strerror(errno) : "");
} else {
fprintf(stdout, "%s %s\n", rc ?
"Fail" : "Pass",
rc ? strerror(errno) : "");
}
fflush(stdout);
free(cmd);
if ((args->args_verbose == 1 && rc) ||
(args->args_verbose >= 2)) {
if ((rc = read(splatctl_fd, splat_buffer,
splat_buffer_size - 1)) < 0) {
fprintf(stdout, "Error reading results: %d\n", rc);
} else {
fprintf(stdout, "\n%s\n", splat_buffer);
fflush(stdout);
}
}
return rc;
}
static int tests_run(cmd_args_t *args)
{
ListIterator i;
test_t *test;
int rc;
fprintf(stdout,
"------------------------------ "
"Running SPLAT Tests "
"------------------------------\n");
i = list_iterator_create(args->args_tests);
while ((test = list_next(i))) {
rc = test_run(args, test);
if (rc && args->args_exit_on_error) {
list_iterator_destroy(i);
return rc;
}
}
list_iterator_destroy(i);
return 0;
}
static int args_parse_test(cmd_args_t *args, char *str)
{
ListIterator si, ti;
subsystem_t *s;
test_t *t;
char *sub_str, *test_str;
int sub_num, test_num;
int sub_all = 0, test_all = 0;
int rc, flag = 0;
test_str = strchr(str, ':');
if (test_str == NULL) {
fprintf(stderr, "Test must be of the "
"form <subsystem:test>\n");
return -EINVAL;
}
sub_str = str;
test_str[0] = '\0';
test_str = test_str + 1;
sub_num = strtol(sub_str, NULL, 0);
test_num = strtol(test_str, NULL, 0);
if (!strncasecmp(sub_str, "all", strlen(sub_str)) || (sub_num == -1))
sub_all = 1;
if (!strncasecmp(test_str,"all",strlen(test_str)) || (test_num == -1))
test_all = 1;
si = list_iterator_create(subsystems);
if (sub_all) {
if (test_all) {
/* Add all tests from all subsystems */
while ((s = list_next(si))) {
ti = list_iterator_create(s->sub_tests);
while ((t = list_next(ti))) {
if ((rc = test_add(args, t))) {
list_iterator_destroy(ti);
goto error_run;
}
}
list_iterator_destroy(ti);
}
} else {
/* Add a specific test from all subsystems */
while ((s = list_next(si))) {
if ((t=test_find(s->sub_desc.name,test_str))) {
if ((rc = test_add(args, t)))
goto error_run;
flag = 1;
}
}
if (!flag)
fprintf(stderr, "No tests '%s:%s' could be "
"found\n", sub_str, test_str);
}
} else {
if (test_all) {
/* Add all tests from a specific subsystem */
while ((s = list_next(si))) {
if (strncasecmp(sub_str, s->sub_desc.name,
strlen(sub_str)))
continue;
ti = list_iterator_create(s->sub_tests);
while ((t = list_next(ti))) {
if ((rc = test_add(args, t))) {
list_iterator_destroy(ti);
goto error_run;
}
}
list_iterator_destroy(ti);
}
} else {
/* Add a specific test from a specific subsystem */
if ((t = test_find(sub_str, test_str))) {
if ((rc = test_add(args, t)))
goto error_run;
} else {
fprintf(stderr, "Test '%s:%s' could not be "
"found\n", sub_str, test_str);
return -EINVAL;
}
}
}
list_iterator_destroy(si);
return 0;
error_run:
list_iterator_destroy(si);
fprintf(stderr, "Test '%s:%s' not added to run list: %d\n",
sub_str, test_str, rc);
return rc;
}
static void args_fini(cmd_args_t *args)
{
assert(args != NULL);
if (args->args_tests != NULL)
list_destroy(args->args_tests);
free(args);
}
static cmd_args_t *
args_init(int argc, char **argv)
{
cmd_args_t *args;
int c, rc;
if (argc == 1) {
usage();
return (cmd_args_t *) NULL;
}
/* Configure and populate the args structures */
args = malloc(sizeof(*args));
if (args == NULL)
return NULL;
memset(args, 0, sizeof(*args));
args->args_verbose = 0;
args->args_do_list = 0;
args->args_do_all = 0;
args->args_do_color = 1;
args->args_exit_on_error = 0;
args->args_tests = list_create((ListDelF)test_fini);
if (args->args_tests == NULL) {
args_fini(args);
return NULL;
}
while ((c = getopt_long(argc, argv, shortOpts, longOpts, NULL)) != -1){
switch (c) {
case 'v': args->args_verbose++; break;
case 'l': args->args_do_list = 1; break;
case 'a': args->args_do_all = 1; break;
case 'c': args->args_do_color = 0; break;
case 'x': args->args_exit_on_error = 1; break;
case 't':
if (args->args_do_all) {
fprintf(stderr, "Option -t <subsystem:test> is "
"useless when used with -a\n");
args_fini(args);
return NULL;
}
rc = args_parse_test(args, argv[optind - 1]);
if (rc) {
args_fini(args);
return NULL;
}
break;
case 'h':
case '?':
usage();
args_fini(args);
return NULL;
default:
fprintf(stderr, "Unknown option '%s'\n",
argv[optind - 1]);
break;
}
}
return args;
}
static int
dev_clear(void)
{
splat_cfg_t cfg;
int rc;
memset(&cfg, 0, sizeof(cfg));
cfg.cfg_magic = SPLAT_CFG_MAGIC;
cfg.cfg_cmd = SPLAT_CFG_BUFFER_CLEAR;
cfg.cfg_arg1 = 0;
rc = ioctl(splatctl_fd, SPLAT_CFG, &cfg);
if (rc)
fprintf(stderr, "Ioctl() error %lu / %d: %d\n",
(unsigned long) SPLAT_CFG, cfg.cfg_cmd, errno);
lseek(splatctl_fd, 0, SEEK_SET);
return rc;
}
static int
dev_size(int size)
{
splat_cfg_t cfg;
int rc;
memset(&cfg, 0, sizeof(cfg));
cfg.cfg_magic = SPLAT_CFG_MAGIC;
cfg.cfg_cmd = SPLAT_CFG_BUFFER_SIZE;
cfg.cfg_arg1 = size;
rc = ioctl(splatctl_fd, SPLAT_CFG, &cfg);
if (rc) {
fprintf(stderr, "Ioctl() error %lu / %d: %d\n",
(unsigned long) SPLAT_CFG, cfg.cfg_cmd, errno);
return rc;
}
return cfg.cfg_rc1;
}
static void
dev_fini(void)
{
if (splat_buffer)
free(splat_buffer);
if (splatctl_fd != -1) {
if (close(splatctl_fd) == -1) {
fprintf(stderr, "Unable to close %s: %d\n",
SPLAT_DEV, errno);
}
}
}
static int
dev_init(void)
{
ListIterator i;
subsystem_t *sub;
int rc;
splatctl_fd = open(SPLAT_DEV, O_RDONLY);
if (splatctl_fd == -1) {
fprintf(stderr, "Unable to open %s: %d\n"
"Is the splat module loaded?\n", SPLAT_DEV, errno);
rc = errno;
goto error;
}
/* Determine kernel module version string */
memset(splat_version, 0, VERSION_SIZE);
if ((rc = read(splatctl_fd, splat_version, VERSION_SIZE - 1)) == -1)
goto error;
if ((rc = dev_clear()))
goto error;
if ((rc = dev_size(0)) < 0)
goto error;
splat_buffer_size = rc;
splat_buffer = (char *)malloc(splat_buffer_size);
if (splat_buffer == NULL) {
rc = -ENOMEM;
goto error;
}
memset(splat_buffer, 0, splat_buffer_size);
/* Determine available subsystems */
if ((rc = subsystem_setup()) != 0)
goto error;
/* Determine available tests for all subsystems */
i = list_iterator_create(subsystems);
while ((sub = list_next(i))) {
if ((rc = test_setup(sub)) != 0) {
list_iterator_destroy(i);
goto error;
}
}
list_iterator_destroy(i);
return 0;
error:
if (splatctl_fd != -1) {
if (close(splatctl_fd) == -1) {
fprintf(stderr, "Unable to close %s: %d\n",
SPLAT_DEV, errno);
}
}
return rc;
}
int
init(void)
{
int rc = 0;
/* Allocate the subsystem list */
subsystems = list_create((ListDelF)subsystem_fini);
if (subsystems == NULL)
rc = ENOMEM;
return rc;
}
void
fini(void)
{
list_destroy(subsystems);
}
int
main(int argc, char **argv)
{
cmd_args_t *args = NULL;
int rc = 0;
/* General init */
if ((rc = init()))
return rc;
/* Device specific init */
if ((rc = dev_init()))
goto out;
/* Argument init and parsing */
if ((args = args_init(argc, argv)) == NULL) {
rc = -1;
goto out;
}
/* Generic kernel version string */
if (args->args_verbose)
fprintf(stdout, "%s", splat_version);
/* Print the available test list and exit */
if (args->args_do_list) {
subsystem_list(subsystems, 0);
goto out;
}
/* Add all available test to the list of tests to run */
if (args->args_do_all) {
if ((rc = test_add_all(args)))
goto out;
}
/* Run all the requested tests */
if ((rc = tests_run(args)))
goto out;
out:
if (args != NULL)
args_fini(args);
dev_fini();
fini();
return rc;
}

View File

@ -1,70 +0,0 @@
/*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPLAT_H
#define _SPLAT_H
#include "list.h"
#include "../include/splat-ctl.h"
#define DEV_NAME "/dev/splatctl"
#define COLOR_BLACK "\033[0;30m"
#define COLOR_DK_GRAY "\033[1;30m"
#define COLOR_BLUE "\033[0;34m"
#define COLOR_LT_BLUE "\033[1;34m"
#define COLOR_GREEN "\033[0;32m"
#define COLOR_LT_GREEN "\033[1;32m"
#define COLOR_CYAN "\033[0;36m"
#define COLOR_LT_CYAN "\033[1;36m"
#define COLOR_RED "\033[0;31m"
#define COLOR_LT_RED "\033[1;31m"
#define COLOR_PURPLE "\033[0;35m"
#define COLOR_LT_PURPLE "\033[1;35m"
#define COLOR_BROWN "\033[0;33m"
#define COLOR_YELLOW "\033[1;33m"
#define COLOR_LT_GRAY "\033[0;37m"
#define COLOR_WHITE "\033[1;37m"
#define COLOR_RESET "\033[0m"
typedef struct subsystem {
splat_user_t sub_desc; /* Subsystem description */
List sub_tests; /* Assocated subsystem tests list */
} subsystem_t;
typedef struct test {
splat_user_t test_desc; /* Test description */
subsystem_t *test_sub; /* Parent subsystem */
} test_t;
typedef struct cmd_args {
int args_verbose; /* Verbose flag */
int args_do_list; /* Display all tests flag */
int args_do_all; /* Run all tests flag */
int args_do_color; /* Colorize output */
int args_exit_on_error; /* Exit on first error flag */
List args_tests; /* Requested subsystems/tests */
} cmd_args_t;
#endif /* _SPLAT_H */

View File

@ -1,2 +0,0 @@
bin_SCRIPTS = splslab.py
EXTRA_DIST = $(bin_SCRIPTS)

View File

@ -1,202 +0,0 @@
#!/usr/bin/python
import sys
import time
import getopt
import re
import signal
from collections import defaultdict
class Stat:
# flag definitions based on the kmem.h
NOTOUCH = 1
NODEBUG = 2
KMEM = 32
VMEM = 64
SLAB = 128
OFFSLAB = 256
NOEMERGENCY = 512
DEADLOCKED = 16384
GROWING = 32768
REAPING = 65536
DESTROY = 131072
fdefs = {
NOTOUCH : "NTCH",
NODEBUG : "NDBG",
KMEM : "KMEM",
VMEM : "VMEM",
SLAB : "SLAB",
OFFSLAB : "OFSL",
NOEMERGENCY : "NEMG",
DEADLOCKED : "DDLK",
GROWING : "GROW",
REAPING : "REAP",
DESTROY : "DSTR"
}
def __init__(self, name, flags, size, alloc, slabsize, objsize):
self._name = name
self._flags = self.f2str(flags)
self._size = size
self._alloc = alloc
self._slabsize = slabsize
self._objsize = objsize
def f2str(self, flags):
fstring = ''
for k in Stat.fdefs.keys():
if flags & k:
fstring = fstring + Stat.fdefs[k] + '|'
fstring = fstring[:-1]
return fstring
class CumulativeStat:
def __init__(self, skey="a"):
self._size = 0
self._alloc = 0
self._pct = 0
self._skey = skey
self._regexp = \
re.compile('(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+');
self._stats = defaultdict(list)
# Add another stat to the dictionary and re-calculate the totals
def add(self, s):
key = 0
if self._skey == "a":
key = s._alloc
else:
key = s._size
self._stats[key].append(s)
self._size = self._size + s._size
self._alloc = self._alloc + s._alloc
if self._size:
self._pct = self._alloc * 100 / self._size
else:
self._pct = 0
# Parse the slab info in the procfs
# Calculate cumulative stats
def slab_update(self):
k = [line.strip() for line in open('/proc/spl/kmem/slab')]
if not k:
sys.stderr.write("No SPL slab stats found\n")
sys.exit(1)
del k[0:2]
for s in k:
if not s:
continue
m = self._regexp.match(s)
if m:
self.add(Stat(m.group(1), int(m.group(2),16), int(m.group(3)),
int(m.group(4)), int(m.group(5)), int(m.group(6))))
else:
sys.stderr.write("Error: unexpected input format\n" % s)
exit(-1)
def show_header(self):
sys.stdout.write("\n%25s %20s %15s %15s %15s %15s\n\n" % \
("cache name", "flags", "size", "alloc", "slabsize", "objsize"))
# Show up to the number of 'rows' of output sorted in descending order
# by the key specified earlier; if rows == 0, all rows are shown
def show(self, rows):
self.show_header()
i = 1
done = False
for k in reversed(sorted(self._stats.keys())):
for s in self._stats[k]:
sys.stdout.write("%25s %20s %15d %15d %15d %15d\n" % \
(s._name, s._flags, s._size, s._alloc, \
s._slabsize, s._objsize))
i = i + 1
if rows != 0 and i > rows:
done = True
break
if done:
break
sys.stdout.write("%25s %36d %15d (%d%%)\n\n" % \
("Totals:", self._size, self._alloc, self._pct))
def usage():
cmd = "Usage: splslab.py [-n|--num-rows] number [-s|--sort-by] " + \
"[interval] [count]";
sys.stderr.write("%s\n" % cmd)
sys.stderr.write("\t-h : print help\n")
sys.stderr.write("\t-n : --num-rows N : limit output to N top " +
"largest slabs (default: all)\n")
sys.stderr.write("\t-s : --sort-by key : sort output in descending " +
"order by total size (s)\n\t\tor allocated size (a) " +
"(default: a)\n")
sys.stderr.write("\tinterval : repeat every interval seconds\n")
sys.stderr.write("\tcount : output statistics count times and exit\n")
def main():
rows = 0
count = 0
skey = "a"
interval = 1
signal.signal(signal.SIGINT, signal.SIG_DFL)
try:
opts, args = getopt.getopt(
sys.argv[1:],
"n:s:h",
[
"num-rows",
"sort-by",
"help"
]
)
except getopt.error as e:
sys.stderr.write("Error: %s\n" % e.msg)
usage()
exit(-1)
i = 1
for opt, arg in opts:
if opt in ('-n', '--num-rows'):
rows = int(arg)
i = i + 2
elif opt in ('-s', '--sort-by'):
if arg != "s" and arg != "a":
sys.stderr.write("Error: invalid sorting key \"%s\"\n" % arg)
usage()
exit(-1)
skey = arg
i = i + 2
elif opt in ('-h', '--help'):
usage()
exit(0)
else:
break
args = sys.argv[i:]
interval = int(args[0]) if len(args) else interval
count = int(args[1]) if len(args) > 1 else count
i = 0
while True:
cs = CumulativeStat(skey)
cs.slab_update()
cs.show(rows)
i = i + 1
if count and i >= count:
break
time.sleep(interval)
return 0
if __name__ == '__main__':
main()

9
config/.gitignore vendored
View File

@ -1,9 +0,0 @@
/compile
/config.guess
/config.sub
/depcomp
/install-sh
/ltmain.sh
/missing
/libtool.m4
/lt*.m4

View File

@ -1,14 +0,0 @@
###############################################################################
# Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
# Copyright (C) 2007 The Regents of the University of California.
# Written by Brian Behlendorf <behlendorf1@llnl.gov>.
###############################################################################
# Common rules for user space components.
###############################################################################
DEFAULT_INCLUDES = -include ${top_builddir}/spl_config.h
AM_LIBTOOLFLAGS = --silent
AM_CPPFLAGS = -D__USE_LARGEFILE64
AM_CFLAGS = -Wall -Wshadow -Wstrict-prototypes -fno-strict-aliasing
AM_CFLAGS += ${DEBUG_CFLAGS}

View File

@ -1,15 +0,0 @@
# Remove default preprocessor define's from config.h
# PACKAGE
# PACKAGE_BUGREPORT
# PACKAGE_NAME
# PACKAGE_STRING
# PACKAGE_TARNAME
# PACKAGE_VERSION
# STDC_HEADERS
# VERSION
BEGIN { RS = "" ; FS = "\n" } \
!/.#define PACKAGE./ && \
!/.#define VERSION./ && \
!/.#define STDC_HEADERS./ \
{ print $0"\n" }

View File

@ -1,58 +0,0 @@
###############################################################################
# Copyright (C) 2010 Lawrence Livermore National Security, LLC.
# Written by Brian Behlendorf <behlendorf1@llnl.gov>.
###############################################################################
# Build targets for DEB packages.
#
# Long term native distro specific Debian style packaging should be added.
# In the short term RPM packages are built and converted to DEB packages
# using alien. If someone familiar with Debian style packaging were to
# update the build system to correctly build Debian style packages I would
# happily take it. Until then we will have to make due with alien.
#
###############################################################################
deb-local:
@(if test "${HAVE_DPKGBUILD}" = "no"; then \
echo -e "\n" \
"*** Required util ${DPKGBUILD} missing. Please install the\n" \
"*** package for your distribution which provides ${DPKGBUILD},\n" \
"*** re-run configure, and try again.\n"; \
exit 1; \
fi; \
if test "${HAVE_ALIEN}" = "no"; then \
echo -e "\n" \
"*** Required util ${ALIEN} missing. Please install the\n" \
"*** package for your distribution which provides ${ALIEN},\n" \
"*** re-run configure, and try again.\n"; \
exit 1; \
fi)
deb-kmod: deb-local rpm-kmod
name=${PACKAGE}; \
version=${VERSION}-${RELEASE}; \
arch=`$(RPM) -qp $${name}-kmod-$${version}.src.rpm --qf %{arch} | tail -1`; \
debarch=`$(DPKG) --print-architecture`; \
pkg1=kmod-$${name}*$${version}.$${arch}.rpm; \
fakeroot $(ALIEN) --bump=0 --scripts --to-deb --target=$$debarch $$pkg1; \
$(RM) $$pkg1
deb-dkms: deb-local rpm-dkms
name=${PACKAGE}; \
version=${VERSION}-${RELEASE}; \
arch=`$(RPM) -qp $${name}-dkms-$${version}.src.rpm --qf %{arch} | tail -1`; \
debarch=`$(DPKG) --print-architecture`; \
pkg1=$${name}-dkms-$${version}.$${arch}.rpm; \
fakeroot $(ALIEN) --bump=0 --scripts --to-deb --target=$$debarch $$pkg1; \
$(RM) $$pkg1
deb-utils: deb-local rpm-utils
name=${PACKAGE}; \
version=${VERSION}-${RELEASE}; \
arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
debarch=`$(DPKG) --print-architecture`; \
pkg1=$${name}-$${version}.$${arch}.rpm; \
fakeroot $(ALIEN) --bump=0 --scripts --to-deb --target=$$debarch $$pkg1; \
$(RM) $$pkg1
deb: deb-kmod deb-dkms deb-utils

View File

@ -0,0 +1,19 @@
dnl #
dnl # PaX Linux 2.6.38 - 3.x API
dnl #
AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
AC_MSG_CHECKING([whether fops->fallocate() exists])
SPL_LINUX_TRY_COMPILE([
#include <linux/fs.h>
],[
long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
struct file_operations_no_const fops __attribute__ ((unused)) = {
.fallocate = fallocate,
};
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
],[
AC_MSG_RESULT(no)
])
])

View File

@ -1,68 +0,0 @@
dnl #
dnl # Linux 2.6.38 - 3.x API
dnl #
AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
AC_MSG_CHECKING([whether fops->fallocate() exists])
SPL_LINUX_TRY_COMPILE([
#include <linux/fs.h>
],[
long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
struct file_operations fops __attribute__ ((unused)) = {
.fallocate = fallocate,
};
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
],[
AC_MSG_RESULT(no)
])
])
dnl #
dnl # Linux 2.6.x - 2.6.37 API
dnl #
AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
AC_MSG_CHECKING([whether iops->fallocate() exists])
SPL_LINUX_TRY_COMPILE([
#include <linux/fs.h>
],[
long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
struct inode_operations fops __attribute__ ((unused)) = {
.fallocate = fallocate,
};
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
],[
AC_MSG_RESULT(no)
])
])
dnl #
dnl # PaX Linux 2.6.38 - 3.x API
dnl #
AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
AC_MSG_CHECKING([whether fops->fallocate() exists])
SPL_LINUX_TRY_COMPILE([
#include <linux/fs.h>
],[
long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
struct file_operations_no_const fops __attribute__ ((unused)) = {
.fallocate = fallocate,
};
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
],[
AC_MSG_RESULT(no)
])
])
dnl #
dnl # The fallocate callback was moved from the inode_operations
dnl # structure to the file_operations structure.
dnl #
AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
SPL_AC_KERNEL_FILE_FALLOCATE
SPL_AC_KERNEL_INODE_FALLOCATE
SPL_AC_PAX_KERNEL_FILE_FALLOCATE
])

58
config/kernel-kmem.m4 Normal file
View File

@ -0,0 +1,58 @@
dnl #
dnl # Enabled by default it provides a minimal level of memory tracking.
dnl # A total count of bytes allocated is kept for each alloc and free.
dnl # Then at module unload time a report to the console will be printed
dnl # if memory was leaked.
dnl #
AC_DEFUN([SPL_AC_DEBUG_KMEM], [
AC_ARG_ENABLE([debug-kmem],
[AS_HELP_STRING([--enable-debug-kmem],
[Enable basic kmem accounting @<:@default=no@:>@])],
[],
[enable_debug_kmem=no])
AS_IF([test "x$enable_debug_kmem" = xyes],
[
KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
DEBUG_KMEM="_with_debug_kmem"
AC_DEFINE([DEBUG_KMEM], [1],
[Define to 1 to enable basic kmem accounting])
], [
DEBUG_KMEM="_without_debug_kmem"
])
AC_SUBST(DEBUG_KMEM)
AC_MSG_CHECKING([whether basic kmem accounting is enabled])
AC_MSG_RESULT([$enable_debug_kmem])
])
dnl #
dnl # Disabled by default it provides detailed memory tracking. This
dnl # feature also requires --enable-debug-kmem to be set. When enabled
dnl # not only will total bytes be tracked but also the location of every
dnl # alloc and free. When the SPL module is unloaded a list of all leaked
dnl # addresses and where they were allocated will be dumped to the console.
dnl # Enabling this feature has a significant impact on performance but it
dnl # makes finding memory leaks pretty straight forward.
dnl #
AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
AC_ARG_ENABLE([debug-kmem-tracking],
[AS_HELP_STRING([--enable-debug-kmem-tracking],
[Enable detailed kmem tracking @<:@default=no@:>@])],
[],
[enable_debug_kmem_tracking=no])
AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
[
KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
[Define to 1 to enable detailed kmem tracking])
], [
DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
])
AC_SUBST(DEBUG_KMEM_TRACKING)
AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
AC_MSG_RESULT([$enable_debug_kmem_tracking])
])

View File

@ -1,19 +0,0 @@
dnl #
dnl # 3.5 API change,
dnl # inode_operations.truncate_range removed
dnl #
AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
AC_MSG_CHECKING([whether truncate_range() inode operation is available])
SPL_LINUX_TRY_COMPILE([
#include <linux/fs.h>
],[
struct inode_operations ops;
ops.truncate_range = NULL;
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
[truncate_range() inode operation is available])
],[
AC_MSG_RESULT(no)
])
])

View File

@ -1,87 +0,0 @@
###############################################################################
# Copyright (C) 2007-2013 Lawrence Livermore National Security, LLC.
# Copyright (C) 2007 The Regents of the University of California.
# Written by Brian Behlendorf <behlendorf1@llnl.gov>.
###############################################################################
# Build targets for RPM packages.
###############################################################################
srpm-kmod:
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-kmod" \
def='${SRPM_DEFINE_COMMON} ${SRPM_DEFINE_KMOD}' srpm-common
srpm-dkms:
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-dkms" \
def='${SRPM_DEFINE_COMMON} ${SRPM_DEFINE_DKMS}' srpm-common
srpm-utils:
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" \
def='${SRPM_DEFINE_COMMON} ${SRPM_DEFINE_UTIL}' srpm-common
srpm: srpm-kmod srpm-dkms srpm-utils
srpms: srpm-kmod srpm-dkms srpm-utils
rpm-kmod: srpm-kmod
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-kmod" \
def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_KMOD}' rpm-common
rpm-dkms: srpm-dkms
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-dkms" \
def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_DKMS}' rpm-common
rpm-utils: srpm-utils
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" \
def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_UTIL}' rpm-common
rpm: rpm-kmod rpm-dkms rpm-utils
rpms: rpm-kmod rpm-dkms rpm-utils
rpm-local:
@(if test "${HAVE_RPMBUILD}" = "no"; then \
echo -e "\n" \
"*** Required util ${RPMBUILD} missing. Please install the\n" \
"*** package for your distribution which provides ${RPMBUILD},\n" \
"*** re-run configure, and try again.\n"; \
exit 1; \
fi; \
mkdir -p $(rpmbuild)/TMP && \
mkdir -p $(rpmbuild)/BUILD && \
mkdir -p $(rpmbuild)/RPMS && \
mkdir -p $(rpmbuild)/SRPMS && \
mkdir -p $(rpmbuild)/SPECS && \
cp ${RPM_SPEC_DIR}/$(rpmspec) $(rpmbuild)/SPECS && \
mkdir -p $(rpmbuild)/SOURCES && \
cp $(top_srcdir)/scripts/kmodtool $(rpmbuild)/SOURCES && \
cp $(distdir).tar.gz $(rpmbuild)/SOURCES)
srpm-common: dist
@(dist=`$(RPM) --eval %{?dist}`; \
rpmpkg=$(pkg)-$(VERSION)-$(RELEASE)$$dist*src.rpm; \
rpmspec=$(pkg).spec; \
rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \
$(MAKE) $(AM_MAKEFLAGS) \
rpmbuild="$$rpmbuild" \
rpmspec="$$rpmspec" \
rpm-local || exit 1; \
LANG=C $(RPMBUILD) \
--define "_tmppath $$rpmbuild/TMP" \
--define "_topdir $$rpmbuild" \
$(def) -bs $$rpmbuild/SPECS/$$rpmspec || exit 1; \
cp $$rpmbuild/SRPMS/$$rpmpkg . || exit 1; \
rm -R $$rpmbuild)
rpm-common:
@(dist=`$(RPM) --eval %{?dist}`; \
rpmpkg=$(pkg)-$(VERSION)-$(RELEASE)$$dist*src.rpm; \
rpmspec=$(pkg).spec; \
rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \
$(MAKE) $(AM_MAKEFLAGS) \
rpmbuild="$$rpmbuild" \
rpmspec="$$rpmspec" \
rpm-local || exit 1; \
LANG=C ${RPMBUILD} \
--define "_tmppath $$rpmbuild/TMP" \
--define "_topdir $$rpmbuild" \
$(def) --rebuild $$rpmpkg || exit 1; \
cp $$rpmbuild/RPMS/*/* . || exit 1; \
rm -R $$rpmbuild)

View File

@ -1,755 +0,0 @@
###############################################################################
# Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
# Copyright (C) 2007 The Regents of the University of California.
# Written by Brian Behlendorf <behlendorf1@llnl.gov>.
###############################################################################
# SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
###############################################################################
AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
SPL_AC_KERNEL
if test "${LINUX_OBJ}" != "${LINUX}"; then
KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
fi
AC_SUBST(KERNELMAKE_PARAMS)
KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
AC_SUBST(KERNELCPPFLAGS)
SPL_AC_TEST_MODULE
SPL_AC_ATOMIC_SPINLOCK
SPL_AC_SHRINKER_CALLBACK
SPL_AC_CTL_NAME
SPL_AC_CONFIG_TRIM_UNUSED_KSYMS
SPL_AC_PDE_DATA
SPL_AC_SET_FS_PWD_WITH_CONST
SPL_AC_2ARGS_VFS_FSYNC
SPL_AC_INODE_TRUNCATE_RANGE
SPL_AC_FS_STRUCT_SPINLOCK
SPL_AC_KUIDGID_T
SPL_AC_KERNEL_FALLOCATE
SPL_AC_CONFIG_ZLIB_INFLATE
SPL_AC_CONFIG_ZLIB_DEFLATE
SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
SPL_AC_SHRINK_CONTROL_STRUCT
SPL_AC_RWSEM_SPINLOCK_IS_RAW
SPL_AC_RWSEM_ACTIVITY
SPL_AC_RWSEM_ATOMIC_LONG_COUNT
SPL_AC_SCHED_RT_HEADER
SPL_AC_SCHED_SIGNAL_HEADER
SPL_AC_4ARGS_VFS_GETATTR
SPL_AC_3ARGS_VFS_GETATTR
SPL_AC_2ARGS_VFS_GETATTR
SPL_AC_USLEEP_RANGE
SPL_AC_KMEM_CACHE_ALLOCFLAGS
SPL_AC_WAIT_ON_BIT
SPL_AC_INODE_LOCK
SPL_AC_GROUP_INFO_GID
SPL_AC_KMEM_CACHE_CREATE_USERCOPY
SPL_AC_WAIT_QUEUE_ENTRY_T
SPL_AC_WAIT_QUEUE_HEAD_ENTRY
SPL_AC_IO_SCHEDULE_TIMEOUT
SPL_AC_KERNEL_WRITE
SPL_AC_KERNEL_READ
SPL_AC_KERNEL_TIMER_FUNCTION_TIMER_LIST
])
AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
modpost=$LINUX/scripts/Makefile.modpost
AC_MSG_CHECKING([kernel file name for module symbols])
if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
if grep -q Modules.symvers $modpost; then
LINUX_SYMBOLS=Modules.symvers
else
LINUX_SYMBOLS=Module.symvers
fi
if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
AC_MSG_ERROR([
*** Please make sure the kernel devel package for your distribution
*** is installed. If you are building with a custom kernel, make sure the
*** kernel is configured, built, and the '--with-linux=PATH' configure
*** option refers to the location of the kernel source.])
fi
else
LINUX_SYMBOLS=NONE
fi
AC_MSG_RESULT($LINUX_SYMBOLS)
AC_SUBST(LINUX_SYMBOLS)
])
AC_DEFUN([SPL_AC_KERNEL], [
AC_ARG_WITH([linux],
AS_HELP_STRING([--with-linux=PATH],
[Path to kernel source]),
[kernelsrc="$withval"])
AC_ARG_WITH([linux-obj],
AS_HELP_STRING([--with-linux-obj=PATH],
[Path to kernel build objects]),
[kernelbuild="$withval"])
AC_MSG_CHECKING([kernel source directory])
if test -z "$kernelsrc"; then
if test -e "/lib/modules/$(uname -r)/source"; then
headersdir="/lib/modules/$(uname -r)/source"
sourcelink=$(readlink -f "$headersdir")
elif test -e "/lib/modules/$(uname -r)/build"; then
headersdir="/lib/modules/$(uname -r)/build"
sourcelink=$(readlink -f "$headersdir")
else
sourcelink=$(ls -1d /usr/src/kernels/* \
/usr/src/linux-* \
2>/dev/null | grep -v obj | tail -1)
fi
if test -n "$sourcelink" && test -e ${sourcelink}; then
kernelsrc=`readlink -f ${sourcelink}`
else
kernelsrc="[Not found]"
fi
else
if test "$kernelsrc" = "NONE"; then
kernsrcver=NONE
fi
withlinux=yes
fi
AC_MSG_RESULT([$kernelsrc])
if test ! -d "$kernelsrc"; then
AC_MSG_ERROR([
*** Please make sure the kernel devel package for your distribution
*** is installed and then try again. If that fails, you can specify the
*** location of the kernel source with the '--with-linux=PATH' option.])
fi
AC_MSG_CHECKING([kernel build directory])
if test -z "$kernelbuild"; then
if test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"; then
kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
kernelbuild=${kernelsrc}-obj/${target_cpu}/default
elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
else
kernelbuild=${kernelsrc}
fi
fi
AC_MSG_RESULT([$kernelbuild])
AC_MSG_CHECKING([kernel source version])
utsrelease1=$kernelbuild/include/linux/version.h
utsrelease2=$kernelbuild/include/linux/utsrelease.h
utsrelease3=$kernelbuild/include/generated/utsrelease.h
if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
utsrelease=linux/version.h
elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
utsrelease=linux/utsrelease.h
elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
utsrelease=generated/utsrelease.h
fi
if test "$utsrelease"; then
kernsrcver=`(echo "#include <$utsrelease>";
echo "kernsrcver=UTS_RELEASE") |
cpp -I $kernelbuild/include |
grep "^kernsrcver=" | cut -d \" -f 2`
if test -z "$kernsrcver"; then
AC_MSG_RESULT([Not found])
AC_MSG_ERROR([*** Cannot determine kernel version.])
fi
else
AC_MSG_RESULT([Not found])
if test "x$enable_linux_builtin" != xyes; then
AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
else
AC_MSG_ERROR([
*** Cannot find UTS_RELEASE definition.
*** Please run 'make prepare' inside the kernel source tree.])
fi
fi
AC_MSG_RESULT([$kernsrcver])
LINUX=${kernelsrc}
LINUX_OBJ=${kernelbuild}
LINUX_VERSION=${kernsrcver}
AC_SUBST(LINUX)
AC_SUBST(LINUX_OBJ)
AC_SUBST(LINUX_VERSION)
SPL_AC_MODULE_SYMVERS
])
dnl #
dnl # Default SPL user configuration
dnl #
AC_DEFUN([SPL_AC_CONFIG_USER], [])
dnl #
dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
dnl # are missing, it is non-fatal, but you will not be able to build
dnl # RPM packages and will be warned if you try too.
dnl #
dnl # By default, the generic spec file will be used because it requires
dnl # minimal dependencies. Distribution specific spec files can be
dnl # placed under the 'rpm/<distribution>' directory and enabled using
dnl # the --with-spec=<distribution> configure option.
dnl #
AC_DEFUN([SPL_AC_RPM], [
RPM=rpm
RPMBUILD=rpmbuild
AC_MSG_CHECKING([whether $RPM is available])
AS_IF([tmp=$($RPM --version 2>/dev/null)], [
RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
HAVE_RPM=yes
AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
],[
HAVE_RPM=no
AC_MSG_RESULT([$HAVE_RPM])
])
AC_MSG_CHECKING([whether $RPMBUILD is available])
AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
HAVE_RPMBUILD=yes
AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
],[
HAVE_RPMBUILD=no
AC_MSG_RESULT([$HAVE_RPMBUILD])
])
RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1"'
RPM_DEFINE_COMMON+=' --define "$(DEBUG_KMEM) 1"'
RPM_DEFINE_COMMON+=' --define "$(DEBUG_KMEM_TRACKING) 1"'
RPM_DEFINE_UTIL=
RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
RPM_DEFINE_KMOD+=' --define "_wrong_version_format_terminate_build 0"'
RPM_DEFINE_DKMS=
SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
SRPM_DEFINE_UTIL=
SRPM_DEFINE_KMOD=
SRPM_DEFINE_DKMS=
RPM_SPEC_DIR="rpm/generic"
AC_ARG_WITH([spec],
AS_HELP_STRING([--with-spec=SPEC],
[Spec files 'generic|redhat']),
[RPM_SPEC_DIR="rpm/$withval"])
AC_MSG_CHECKING([whether spec files are available])
AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
AC_SUBST(HAVE_RPM)
AC_SUBST(RPM)
AC_SUBST(RPM_VERSION)
AC_SUBST(HAVE_RPMBUILD)
AC_SUBST(RPMBUILD)
AC_SUBST(RPMBUILD_VERSION)
AC_SUBST(RPM_SPEC_DIR)
AC_SUBST(RPM_DEFINE_UTIL)
AC_SUBST(RPM_DEFINE_KMOD)
AC_SUBST(RPM_DEFINE_DKMS)
AC_SUBST(RPM_DEFINE_COMMON)
AC_SUBST(SRPM_DEFINE_UTIL)
AC_SUBST(SRPM_DEFINE_KMOD)
AC_SUBST(SRPM_DEFINE_DKMS)
AC_SUBST(SRPM_DEFINE_COMMON)
])
dnl #
dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
dnl # tools are missing it is non-fatal but you will not be able to build
dnl # DEB packages and will be warned if you try too.
dnl #
AC_DEFUN([SPL_AC_DPKG], [
DPKG=dpkg
DPKGBUILD=dpkg-buildpackage
AC_MSG_CHECKING([whether $DPKG is available])
AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
HAVE_DPKG=yes
AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
],[
HAVE_DPKG=no
AC_MSG_RESULT([$HAVE_DPKG])
])
AC_MSG_CHECKING([whether $DPKGBUILD is available])
AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
DPKGBUILD_VERSION=$(echo $tmp | \
$AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
HAVE_DPKGBUILD=yes
AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
],[
HAVE_DPKGBUILD=no
AC_MSG_RESULT([$HAVE_DPKGBUILD])
])
AC_SUBST(HAVE_DPKG)
AC_SUBST(DPKG)
AC_SUBST(DPKG_VERSION)
AC_SUBST(HAVE_DPKGBUILD)
AC_SUBST(DPKGBUILD)
AC_SUBST(DPKGBUILD_VERSION)
])
dnl #
dnl # Until native packaging for various different packing systems
dnl # can be added the least we can do is attempt to use alien to
dnl # convert the RPM packages to the needed package type. This is
dnl # a hack but so far it has worked reasonable well.
dnl #
AC_DEFUN([SPL_AC_ALIEN], [
ALIEN=alien
AC_MSG_CHECKING([whether $ALIEN is available])
AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
HAVE_ALIEN=yes
AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
],[
HAVE_ALIEN=no
AC_MSG_RESULT([$HAVE_ALIEN])
])
AC_SUBST(HAVE_ALIEN)
AC_SUBST(ALIEN)
AC_SUBST(ALIEN_VERSION)
])
dnl #
dnl # Using the VENDOR tag from config.guess set the default
dnl # package type for 'make pkg': (rpm | deb | tgz)
dnl #
AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
AC_MSG_CHECKING([linux distribution])
if test -f /etc/toss-release ; then
VENDOR=toss ;
elif test -f /etc/fedora-release ; then
VENDOR=fedora ;
elif test -f /etc/redhat-release ; then
VENDOR=redhat ;
elif test -f /etc/gentoo-release ; then
VENDOR=gentoo ;
elif test -f /etc/arch-release ; then
VENDOR=arch ;
elif test -f /etc/SuSE-release ; then
VENDOR=sles ;
elif test -f /etc/slackware-version ; then
VENDOR=slackware ;
elif test -f /etc/lunar.release ; then
VENDOR=lunar ;
elif test -f /etc/lsb-release ; then
VENDOR=ubuntu ;
elif test -f /etc/debian_version ; then
VENDOR=debian ;
else
VENDOR= ;
fi
AC_MSG_RESULT([$VENDOR])
AC_SUBST(VENDOR)
AC_MSG_CHECKING([default package type])
case "$VENDOR" in
toss) DEFAULT_PACKAGE=rpm ;;
redhat) DEFAULT_PACKAGE=rpm ;;
fedora) DEFAULT_PACKAGE=rpm ;;
gentoo) DEFAULT_PACKAGE=tgz ;;
arch) DEFAULT_PACKAGE=tgz ;;
sles) DEFAULT_PACKAGE=rpm ;;
slackware) DEFAULT_PACKAGE=tgz ;;
lunar) DEFAULT_PACKAGE=tgz ;;
ubuntu) DEFAULT_PACKAGE=deb ;;
debian) DEFAULT_PACKAGE=deb ;;
*) DEFAULT_PACKAGE=rpm ;;
esac
AC_MSG_RESULT([$DEFAULT_PACKAGE])
AC_SUBST(DEFAULT_PACKAGE)
])
dnl #
dnl # Default SPL user configuration
dnl #
AC_DEFUN([SPL_AC_PACKAGE], [
SPL_AC_DEFAULT_PACKAGE
SPL_AC_RPM
SPL_AC_DPKG
SPL_AC_ALIEN
])
AC_DEFUN([SPL_AC_LICENSE], [
AC_MSG_CHECKING([spl author])
AC_MSG_RESULT([$SPL_META_AUTHOR])
AC_MSG_CHECKING([spl license])
AC_MSG_RESULT([$SPL_META_LICENSE])
])
AC_DEFUN([SPL_AC_CONFIG], [
SPL_CONFIG=all
AC_ARG_WITH([config],
AS_HELP_STRING([--with-config=CONFIG],
[Config file 'kernel|user|all|srpm']),
[SPL_CONFIG="$withval"])
AC_ARG_ENABLE([linux-builtin],
[AC_HELP_STRING([--enable-linux-builtin],
[Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
[],
[enable_linux_builtin=no])
AC_MSG_CHECKING([spl config])
AC_MSG_RESULT([$SPL_CONFIG]);
AC_SUBST(SPL_CONFIG)
case "$SPL_CONFIG" in
kernel) SPL_AC_CONFIG_KERNEL ;;
user) SPL_AC_CONFIG_USER ;;
all) SPL_AC_CONFIG_KERNEL
SPL_AC_CONFIG_USER ;;
srpm) ;;
*)
AC_MSG_RESULT([Error!])
AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
user kernel|user|all|srpm]) ;;
esac
AM_CONDITIONAL([CONFIG_USER],
[test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
AM_CONDITIONAL([CONFIG_KERNEL],
[test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
[test "x$enable_linux_builtin" != xyes ])
])
dnl #
dnl # Enable if the SPL should be compiled with internal debugging enabled.
dnl # By default this support is disabled.
dnl #
AC_DEFUN([SPL_AC_DEBUG], [
AC_MSG_CHECKING([whether debugging is enabled])
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[Enable generic debug support @<:@default=no@:>@])],
[],
[enable_debug=no])
AS_IF([test "x$enable_debug" = xyes],
[
KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
DEBUG_CFLAGS="-DDEBUG -Werror"
DEBUG_SPL="_with_debug"
], [
KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
DEBUG_CFLAGS="-DNDEBUG"
DEBUG_SPL="_without_debug"
])
AC_SUBST(DEBUG_CFLAGS)
AC_SUBST(DEBUG_SPL)
AC_MSG_RESULT([$enable_debug])
])
dnl #
dnl # Enabled by default it provides a minimal level of memory tracking.
dnl # A total count of bytes allocated is kept for each alloc and free.
dnl # Then at module unload time a report to the console will be printed
dnl # if memory was leaked.
dnl #
AC_DEFUN([SPL_AC_DEBUG_KMEM], [
AC_ARG_ENABLE([debug-kmem],
[AS_HELP_STRING([--enable-debug-kmem],
[Enable basic kmem accounting @<:@default=no@:>@])],
[],
[enable_debug_kmem=no])
AS_IF([test "x$enable_debug_kmem" = xyes],
[
KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
DEBUG_KMEM="_with_debug_kmem"
AC_DEFINE([DEBUG_KMEM], [1],
[Define to 1 to enable basic kmem accounting])
], [
DEBUG_KMEM="_without_debug_kmem"
])
AC_SUBST(DEBUG_KMEM)
AC_MSG_CHECKING([whether basic kmem accounting is enabled])
AC_MSG_RESULT([$enable_debug_kmem])
])
dnl #
dnl # Disabled by default it provides detailed memory tracking. This
dnl # feature also requires --enable-debug-kmem to be set. When enabled
dnl # not only will total bytes be tracked but also the location of every
dnl # alloc and free. When the SPL module is unloaded a list of all leaked
dnl # addresses and where they were allocated will be dumped to the console.
dnl # Enabling this feature has a significant impact on performance but it
dnl # makes finding memory leaks pretty straight forward.
dnl #
AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
AC_ARG_ENABLE([debug-kmem-tracking],
[AS_HELP_STRING([--enable-debug-kmem-tracking],
[Enable detailed kmem tracking @<:@default=no@:>@])],
[],
[enable_debug_kmem_tracking=no])
AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
[
KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
[Define to 1 to enable detailed kmem tracking])
], [
DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
])
AC_SUBST(DEBUG_KMEM_TRACKING)
AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
AC_MSG_RESULT([$enable_debug_kmem_tracking])
])
dnl #
dnl # SPL_LINUX_CONFTEST
dnl #
AC_DEFUN([SPL_LINUX_CONFTEST], [
cat confdefs.h - <<_ACEOF >conftest.c
$1
_ACEOF
])
dnl #
dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
dnl #
m4_define([SPL_LANG_PROGRAM], [
$1
int
main (void)
{
dnl Do *not* indent the following line: there may be CPP directives.
dnl Don't move the `;' right after for the same reason.
$2
;
return 0;
}
])
dnl #
dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
dnl #
AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
rm -Rf build && mkdir -p build && touch build/conftest.mod.c
echo "obj-m := conftest.o" >build/Makefile
modpost_flag=''
test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
AS_IF(
[AC_TRY_COMMAND(cp conftest.c build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag) >/dev/null && AC_TRY_COMMAND([$3])],
[$4],
[_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
)
rm -Rf build
])
dnl #
dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
dnl #
AC_DEFUN([SPL_LINUX_TRY_COMPILE],
[SPL_LINUX_COMPILE_IFELSE(
[AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
[modules],
[test -s build/conftest.o],
[$3], [$4])
])
dnl #
dnl # SPL_CHECK_SYMBOL_EXPORT
dnl # check symbol exported or not
dnl #
AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
$LINUX_OBJ/Module*.symvers 2>/dev/null
rc=$?
if test $rc -ne 0; then
export=0
for file in $2; do
grep -q -E "EXPORT_SYMBOL.*($1)" \
"$LINUX_OBJ/$file" 2>/dev/null
rc=$?
if test $rc -eq 0; then
export=1
break;
fi
done
if test $export -eq 0; then :
$4
else :
$3
fi
else :
$3
fi
])
dnl #
dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
dnl # is called if not compiling for builtin
dnl #
AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
if test $rc -ne 0; then :
$6
else
if test "x$enable_linux_builtin" != xyes; then
SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
fi
if test $rc -ne 0; then :
$6
else :
$5
fi
fi
])
dnl #
dnl # SPL_CHECK_SYMBOL_HEADER
dnl # check if a symbol prototype is defined in listed headers.
dnl #
AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
AC_MSG_CHECKING([whether symbol $1 exists in header])
header=0
for file in $3; do
grep -q "$2" "$LINUX/$file" 2>/dev/null
rc=$?
if test $rc -eq 0; then
header=1
break;
fi
done
if test $header -eq 0; then
AC_MSG_RESULT([no])
$5
else
AC_MSG_RESULT([yes])
$4
fi
])
dnl #
dnl # SPL_CHECK_HEADER
dnl # check whether header exists and define HAVE_$2_HEADER
dnl #
AC_DEFUN([SPL_CHECK_HEADER],
[AC_MSG_CHECKING([whether header $1 exists])
SPL_LINUX_TRY_COMPILE([
#include <$1>
],[
return 0;
],[
AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
AC_MSG_RESULT(yes)
$3
],[
AC_MSG_RESULT(no)
$4
])
])
dnl #
dnl # Basic toolchain sanity check. Verify that kernel modules can
dnl # be built and which symbols can be used.
dnl #
AC_DEFUN([SPL_AC_TEST_MODULE],
[AC_MSG_CHECKING([whether modules can be built])
SPL_LINUX_TRY_COMPILE([],[],[
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
if test "x$enable_linux_builtin" != xyes; then
AC_MSG_ERROR([*** Unable to build an empty module.])
else
AC_MSG_ERROR([
*** Unable to build an empty module.
*** Please run 'make scripts' inside the kernel source tree.])
fi
])
AS_IF([test "x$cross_compiling" != xyes], [
AC_RUN_IFELSE([
AC_LANG_PROGRAM([
#include "$LINUX/include/linux/license.h"
], [
return !license_is_gpl_compatible(
"$SPL_META_LICENSE");
])
], [
AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
[Define to 1 if GPL-only symbols can be used])
], [
])
])
])
dnl #
dnl # Use the atomic implemenation based on global spinlocks. This
dnl # should only be needed by 32-bit kernels which do not provide
dnl # the atomic64_* API. It may be optionally enabled as a fallback
dnl # if problems are observed with the direct mapping to the native
dnl # Linux atomic operations. You may not disable atomic spinlocks
dnl # if you kernel does not an atomic64_* API.
dnl #
AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
AC_ARG_ENABLE([atomic-spinlocks],
[AS_HELP_STRING([--enable-atomic-spinlocks],
[Atomic types use spinlocks @<:@default=check@:>@])],
[],
[enable_atomic_spinlocks=check])
SPL_LINUX_TRY_COMPILE([
#include <linux/fs.h>
],[
atomic64_t *ptr __attribute__ ((unused));
],[
have_atomic64_t=yes
AC_DEFINE(HAVE_ATOMIC64_T, 1,
[kernel defines atomic64_t])
],[
have_atomic64_t=no
])
AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
AS_IF([test "x$have_atomic64_t" = xyes], [
enable_atomic_spinlocks=no
],[
enable_atomic_spinlocks=yes
])
])
AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
AC_DEFINE([ATOMIC_SPINLOCK], [1],
[Atomic types use spinlocks])
],[
AS_IF([test "x$have_atomic64_t" = xno], [
AC_MSG_FAILURE(
[--disable-atomic-spinlocks given but required atomic64 support is unavailable])
])
])
AC_MSG_CHECKING([whether atomic types use spinlocks])
AC_MSG_RESULT([$enable_atomic_spinlocks])
AC_MSG_CHECKING([whether kernel defines atomic64_t])
AC_MSG_RESULT([$have_atomic64_t])
])

View File

@ -1,170 +0,0 @@
dnl #
dnl # DESCRIPTION:
dnl # Read meta data from the META file. When building from a git repository
dnl # the SPL_META_RELEASE field will be overwritten if there is an annotated
dnl # tag matching the form SPL_META_NAME-SPL_META_VERSION-*. This allows
dnl # for working builds to be uniquely identified using the git commit hash.
dnl #
dnl # The META file format is as follows:
dnl # ^[ ]*KEY:[ \t]+VALUE$
dnl #
dnl # In other words:
dnl # - KEY is separated from VALUE by a colon and one or more spaces/tabs.
dnl # - KEY and VALUE are case sensitive.
dnl # - Leading spaces are ignored.
dnl # - First match wins for duplicate keys.
dnl #
dnl # A line can be commented out by preceding it with a '#' (or technically
dnl # any non-space character since that will prevent the regex from
dnl # matching).
dnl #
dnl # WARNING:
dnl # Placing a colon followed by a space or tab (ie, ":[ \t]+") within the
dnl # VALUE will prematurely terminate the string since that sequence is
dnl # used as the awk field separator.
dnl #
dnl # KEYS:
dnl # The following META keys are recognized:
dnl # Name, Version, Release, Date, Author, LT_Current, LT_Revision, LT_Age
dnl #
dnl # Written by Chris Dunlap <cdunlap@llnl.gov>.
dnl # Modified by Brian Behlendorf <behlendorf1@llnl.gov>.
dnl #
AC_DEFUN([SPL_AC_META], [
AC_PROG_AWK
AC_MSG_CHECKING([metadata])
META="$srcdir/META"
_spl_ac_meta_type="none"
if test -f "$META"; then
_spl_ac_meta_type="META file"
SPL_META_NAME=_SPL_AC_META_GETVAL([(Name|Project|Package)]);
if test -n "$SPL_META_NAME"; then
AC_DEFINE_UNQUOTED([SPL_META_NAME], ["$SPL_META_NAME"],
[Define the project name.]
)
AC_SUBST([SPL_META_NAME])
fi
SPL_META_VERSION=_SPL_AC_META_GETVAL([Version]);
if test -n "$SPL_META_VERSION"; then
AC_DEFINE_UNQUOTED([SPL_META_VERSION], ["$SPL_META_VERSION"],
[Define the project version.]
)
AC_SUBST([SPL_META_VERSION])
fi
SPL_META_RELEASE=_SPL_AC_META_GETVAL([Release]);
if test ! -f ".nogitrelease" && git rev-parse --git-dir > /dev/null 2>&1; then
_match="${SPL_META_NAME}-${SPL_META_VERSION}"
_alias=$(git describe --match=${_match} 2>/dev/null)
_release=$(echo ${_alias}|cut -f3- -d'-'|sed 's/-/_/g')
if test -n "${_release}"; then
SPL_META_RELEASE=${_release}
_spl_ac_meta_type="git describe"
else
_match="${SPL_META_NAME}-${SPL_META_VERSION}-${SPL_META_RELEASE}"
_alias=$(git describe --match=${_match} 2>/dev/null)
_release=$(echo ${_alias}|cut -f3- -d'-'|sed 's/-/_/g')
if test -n "${_release}"; then
SPL_META_RELEASE=${_release}
_spl_ac_meta_type="git describe"
fi
fi
fi
if test -n "$SPL_META_RELEASE"; then
AC_DEFINE_UNQUOTED([SPL_META_RELEASE], ["$SPL_META_RELEASE"],
[Define the project release.]
)
AC_SUBST([SPL_META_RELEASE])
RELEASE="$SPL_META_RELEASE"
AC_SUBST([RELEASE])
fi
SPL_META_LICENSE=_SPL_AC_META_GETVAL([License]);
if test -n "$SPL_META_LICENSE"; then
AC_DEFINE_UNQUOTED([SPL_META_LICENSE], ["$SPL_META_LICENSE"],
[Define the project license.]
)
AC_SUBST([SPL_META_LICENSE])
fi
if test -n "$SPL_META_NAME" -a -n "$SPL_META_VERSION"; then
SPL_META_ALIAS="$SPL_META_NAME-$SPL_META_VERSION"
test -n "$SPL_META_RELEASE" &&
SPL_META_ALIAS="$SPL_META_ALIAS-$SPL_META_RELEASE"
AC_DEFINE_UNQUOTED([SPL_META_ALIAS],
["$SPL_META_ALIAS"],
[Define the project alias string.]
)
AC_SUBST([SPL_META_ALIAS])
fi
SPL_META_DATA=_SPL_AC_META_GETVAL([Date]);
if test -n "$SPL_META_DATA"; then
AC_DEFINE_UNQUOTED([SPL_META_DATA], ["$SPL_META_DATA"],
[Define the project release date.]
)
AC_SUBST([SPL_META_DATA])
fi
SPL_META_AUTHOR=_SPL_AC_META_GETVAL([Author]);
if test -n "$SPL_META_AUTHOR"; then
AC_DEFINE_UNQUOTED([SPL_META_AUTHOR], ["$SPL_META_AUTHOR"],
[Define the project author.]
)
AC_SUBST([SPL_META_AUTHOR])
fi
m4_pattern_allow([^LT_(CURRENT|REVISION|AGE)$])
SPL_META_LT_CURRENT=_SPL_AC_META_GETVAL([LT_Current]);
SPL_META_LT_REVISION=_SPL_AC_META_GETVAL([LT_Revision]);
SPL_META_LT_AGE=_SPL_AC_META_GETVAL([LT_Age]);
if test -n "$SPL_META_LT_CURRENT" \
-o -n "$SPL_META_LT_REVISION" \
-o -n "$SPL_META_LT_AGE"; then
test -n "$SPL_META_LT_CURRENT" || SPL_META_LT_CURRENT="0"
test -n "$SPL_META_LT_REVISION" || SPL_META_LT_REVISION="0"
test -n "$SPL_META_LT_AGE" || SPL_META_LT_AGE="0"
AC_DEFINE_UNQUOTED([SPL_META_LT_CURRENT],
["$SPL_META_LT_CURRENT"],
[Define the libtool library 'current'
version information.]
)
AC_DEFINE_UNQUOTED([SPL_META_LT_REVISION],
["$SPL_META_LT_REVISION"],
[Define the libtool library 'revision'
version information.]
)
AC_DEFINE_UNQUOTED([SPL_META_LT_AGE], ["$SPL_META_LT_AGE"],
[Define the libtool library 'age'
version information.]
)
AC_SUBST([SPL_META_LT_CURRENT])
AC_SUBST([SPL_META_LT_REVISION])
AC_SUBST([SPL_META_LT_AGE])
fi
fi
AC_MSG_RESULT([$_spl_ac_meta_type])
]
)
dnl # _SPL_AC_META_GETVAL (KEY_NAME_OR_REGEX)
dnl #
dnl # Returns the META VALUE associated with the given KEY_NAME_OR_REGEX expr.
dnl #
dnl # Despite their resemblance to line noise,
dnl # the "@<:@" and "@:>@" constructs are quadrigraphs for "[" and "]".
dnl # <www.gnu.org/software/autoconf/manual/autoconf.html#Quadrigraphs>
dnl #
dnl # The "$[]1" and "$[]2" constructs prevent M4 parameter expansion
dnl # so a literal $1 and $2 will be passed to the resulting awk script,
dnl # whereas the "$1" will undergo M4 parameter expansion for the META key.
dnl #
AC_DEFUN([_SPL_AC_META_GETVAL],
[`$AWK -F ':@<:@ \t@:>@+' '$[]1 ~ /^ *$1$/ { print $[]2; exit }' $META`]dnl
)

View File

@ -1,44 +0,0 @@
###############################################################################
# Copyright (C) 2010 Lawrence Livermore National Security, LLC.
# Written by Brian Behlendorf <behlendorf1@llnl.gov>.
###############################################################################
# Build targets for TGZ packages.
#
# Long term native distro specific Slackware style packaging should be added.
# In the short term RPM packages are built and converted to TGZ packages
# using alien. If someone familiar with Slackware style packaging were to
# update the build system to correctly build Slackware style packages I would
# happily take it. Until then we will have to make due with alien.
#
###############################################################################
tgz-local:
@(if test "${HAVE_ALIEN}" = "no"; then \
echo -e "\n" \
"*** Required util ${ALIEN} missing. Please install the\n" \
"*** package for your distribution which provides ${ALIEN},\n" \
"*** re-run configure, and try again.\n"; \
exit 1; \
fi)
tgz-kmod: tgz-local rpm-kmod
if CONFIG_KERNEL
name=${PACKAGE}; \
version=${VERSION}-${RELEASE}; \
arch=`$(RPM) -qp $${name}-kmod-$${version}.src.rpm --qf %{arch} | tail -1`; \
pkg1=kmod-$${name}*$${version}.$${arch}.rpm; \
fakeroot $(ALIEN) --scripts --to-tgz $$pkg1; \
$(RM) $$pkg1
endif
tgz-utils: tgz-local rpm-utils
if CONFIG_USER
name=${PACKAGE}; \
version=${VERSION}-${RELEASE}; \
arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
pkg1=$${name}-$${version}.$${arch}.rpm; \
fakeroot $(ALIEN) --scripts --to-tgz $$pkg1; \
$(RM) $$pkg1
endif
tgz: tgz-kmod tgz-utils

View File

@ -1,88 +0,0 @@
###############################################################################
# SPL AutoConf Configuration
###############################################################################
# Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
# Copyright (C) 2007 The Regents of the University of California.
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
# Written by Brian Behlendorf <behlendorf1@llnl.gov>.
# UCRL-CODE-235197
#
# This file is part of the SPL, Solaris Porting Layer.
# For details, see <http://zfsonlinux.org/>.
#
# The SPL is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# The SPL is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with the SPL. If not, see <http://www.gnu.org/licenses/>.
###############################################################################
AC_INIT(m4_esyscmd(grep Name META | cut -d ':' -f 2 | tr -d ' \n'),
m4_esyscmd(grep Version META | cut -d ':' -f 2 | tr -d ' \n'))
AC_LANG(C)
SPL_AC_META
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_MACRO_DIR([config])
AC_CANONICAL_SYSTEM
AM_MAINTAINER_MODE
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS([spl_config.h], [
(mv spl_config.h spl_config.h.tmp &&
awk -f ${ac_srcdir}/config/config.awk spl_config.h.tmp >spl_config.h &&
rm spl_config.h.tmp) || exit 1])
AC_PROG_INSTALL
AC_PROG_CC
AC_PROG_LIBTOOL
SPL_AC_LICENSE
SPL_AC_PACKAGE
SPL_AC_CONFIG
SPL_AC_DEBUG
SPL_AC_DEBUG_KMEM
SPL_AC_DEBUG_KMEM_TRACKING
AC_CONFIG_FILES([
Makefile
man/Makefile
man/man1/Makefile
man/man5/Makefile
lib/Makefile
cmd/Makefile
cmd/splat/Makefile
cmd/splslab/Makefile
module/Makefile
module/spl/Makefile
module/splat/Makefile
include/Makefile
include/fs/Makefile
include/linux/Makefile
include/rpc/Makefile
include/sharefs/Makefile
include/sys/Makefile
include/sys/fm/Makefile
include/sys/fs/Makefile
include/util/Makefile
include/vm/Makefile
scripts/Makefile
rpm/Makefile
rpm/redhat/Makefile
rpm/redhat/spl.spec
rpm/redhat/spl-kmod.spec
rpm/redhat/spl-dkms.spec
rpm/generic/Makefile
rpm/generic/spl.spec
rpm/generic/spl-kmod.spec
rpm/generic/spl-dkms.spec
spl.release
])
AC_OUTPUT

View File

@ -1,126 +0,0 @@
#!/bin/bash
set -e
usage()
{
echo "usage: $0 <kernel source tree>" >&2
exit 1
}
[ "$#" -eq 1 ] || usage
KERNEL_DIR="$(readlink --canonicalize-existing "$1")"
MODULES=()
for MODULE_DIR in module/*
do
[ -d "$MODULE_DIR" ] || continue
MODULES+=("${MODULE_DIR##*/}")
done
if ! [ -e 'spl_config.h' ]
then
echo >&2
echo " $0: you did not run configure, or you're not in the SPL source directory." >&2
echo " $0: run configure with --with-linux=$KERNEL_DIR and --enable-linux-builtin." >&2
echo >&2
exit 1
fi
make clean || true
rm -rf "$KERNEL_DIR/include/spl" "$KERNEL_DIR/spl"
cp --recursive include "$KERNEL_DIR/include/spl"
cp --recursive module "$KERNEL_DIR/spl"
cp spl_config.h "$KERNEL_DIR/"
cp spl.release.in "$KERNEL_DIR/"
adjust_obj_paths()
{
local FILE="$1"
local LINE OBJPATH
while IFS='' read -r LINE
do
OBJPATH="${LINE#\$(MODULE)-objs += }"
if [ "$OBJPATH" = "$LINE" ]
then
echo "$LINE"
else
echo "\$(MODULE)-objs += ${OBJPATH##*/}"
fi
done < "$FILE" > "$FILE.new"
mv "$FILE.new" "$FILE"
}
for MODULE in "${MODULES[@]}"
do
adjust_obj_paths "$KERNEL_DIR/spl/$MODULE/Makefile"
sed -i.bak '/obj =/d' "$KERNEL_DIR/spl/$MODULE/Makefile"
sed -i.bak '/src =/d' "$KERNEL_DIR/spl/$MODULE/Makefile"
done
cat > "$KERNEL_DIR/spl/Kconfig" <<"EOF"
config SPL
tristate "Solaris Porting Layer (SPL)"
help
This is the SPL library from the ZFS On Linux project.
See http://zfsonlinux.org/
To compile this library as a module, choose M here.
If unsure, say N.
EOF
{
cat <<-"EOF"
SPL_MODULE_CFLAGS = -I$(srctree)/include/spl
SPL_MODULE_CFLAGS += -include $(srctree)/spl_config.h
export SPL_MODULE_CFLAGS
obj-$(CONFIG_SPL) :=
EOF
for MODULE in "${MODULES[@]}"
do
echo 'obj-$(CONFIG_SPL) += ' "$MODULE/"
done
} > "$KERNEL_DIR/spl/Kbuild"
add_after()
{
local FILE="$1"
local MARKER="$2"
local NEW="$3"
local LINE
while IFS='' read -r LINE
do
echo "$LINE"
if [ -n "$MARKER" -a "$LINE" = "$MARKER" ]
then
echo "$NEW"
MARKER=''
if IFS='' read -r LINE
then
[ "$LINE" != "$NEW" ] && echo "$LINE"
fi
fi
done < "$FILE" > "$FILE.new"
mv "$FILE.new" "$FILE"
}
add_after "$KERNEL_DIR/Kconfig" 'source "arch/$SRCARCH/Kconfig"' 'source "spl/Kconfig"'
# We must take care to build SPL before ZFS, otherwise the symbols required
# to link ZFS will not be available.
sed -i 's~mm/ fs/~mm/ spl/ fs/~' "$KERNEL_DIR/Makefile"
echo >&2
echo " $0: done." >&2
echo " $0: now you can build the kernel with SPL support." >&2
echo " $0: make sure you enable SPL support (CONFIG_SPL) before building." >&2
echo >&2

View File

@ -1,18 +0,0 @@
SUBDIRS = fs linux rpc sharefs sys util vm
COMMON_H =
KERNEL_H = \
$(top_srcdir)/include/splat-ctl.h \
$(top_srcdir)/include/spl-ctl.h \
$(top_srcdir)/include/strings.h \
$(top_srcdir)/include/unistd.h
USER_H =
EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
if CONFIG_KERNEL
kerneldir = @prefix@/src/spl-$(VERSION)/include
kernel_HEADERS = $(KERNEL_H)
endif

View File

@ -1,13 +0,0 @@
COMMON_H =
KERNEL_H = \
$(top_srcdir)/include/fs/fs_subr.h
USER_H =
EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
if CONFIG_KERNEL
kerneldir = @prefix@/src/spl-$(VERSION)/include/fs
kernel_HEADERS = $(KERNEL_H)
endif

View File

@ -1,28 +0,0 @@
/*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_FS_FS_SUBR_H
#define _SPL_FS_FS_SUBR_H
#endif /* SPL_FS_FS_SUBR_H */

View File

@ -1,23 +0,0 @@
COMMON_H =
KERNEL_H = \
$(top_srcdir)/include/linux/bitops_compat.h \
$(top_srcdir)/include/linux/compiler_compat.h \
$(top_srcdir)/include/linux/delay_compat.h \
$(top_srcdir)/include/linux/file_compat.h \
$(top_srcdir)/include/linux/list_compat.h \
$(top_srcdir)/include/linux/math64_compat.h \
$(top_srcdir)/include/linux/mm_compat.h \
$(top_srcdir)/include/linux/proc_compat.h \
$(top_srcdir)/include/linux/rwsem_compat.h \
$(top_srcdir)/include/linux/wait_compat.h \
$(top_srcdir)/include/linux/zlib_compat.h
USER_H =
EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
if CONFIG_KERNEL
kerneldir = @prefix@/src/spl-$(VERSION)/include/linux
kernel_HEADERS = $(KERNEL_H)
endif

View File

@ -1,30 +0,0 @@
/*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_BITOPS_COMPAT_H
#define _SPL_BITOPS_COMPAT_H
#include <linux/bitops.h>
#endif /* _SPL_BITOPS_COMPAT_H */

View File

@ -1,47 +0,0 @@
/*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_COMPILER_COMPAT_H
#define _SPL_COMPILER_COMPAT_H
#include <linux/compiler.h>
#ifndef ACCESS_ONCE
/*
* Prevent the compiler from merging or refetching accesses. The compiler
* is also forbidden from reordering successive instances of ACCESS_ONCE(),
* but only when the compiler is aware of some particular ordering. One way
* to make the compiler aware of ordering is to put the two invocations of
* ACCESS_ONCE() in different C statements.
*
* This macro does absolutely -nothing- to prevent the CPU from reordering,
* merging, or refetching absolutely anything at any time. Its main intended
* use is to mediate communication between process-level code and irq/NMI
* handlers, all running on the same CPU.
*/
/* Taken from 2.6.33.2 */
#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
#endif
#endif /* _SPL_COMPILER_COMPAT_H */

View File

@ -1,47 +0,0 @@
/*
* Copyright (C) 2007-2013 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_DELAY_COMPAT_H
#define _SPL_DELAY_COMPAT_H
#include <linux/delay.h>
#include <linux/time.h>
/* usleep_range() introduced in 2.6.36 */
#ifndef HAVE_USLEEP_RANGE
static inline void
usleep_range(unsigned long min, unsigned long max)
{
unsigned int min_ms = min / USEC_PER_MSEC;
if (min >= MAX_UDELAY_MS)
msleep(min_ms);
else
udelay(min);
}
#endif /* HAVE_USLEEP_RANGE */
#endif /* _SPL_DELAY_COMPAT_H */

View File

@ -1,140 +0,0 @@
/*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_FILE_COMPAT_H
#define _SPL_FILE_COMPAT_H
#include <linux/fs.h>
#include <linux/uaccess.h>
#ifdef HAVE_FDTABLE_HEADER
#include <linux/fdtable.h>
#endif
static inline struct file *
spl_filp_open(const char *name, int flags, int mode, int *err)
{
struct file *filp = NULL;
int rc;
filp = filp_open(name, flags, mode);
if (IS_ERR(filp)) {
rc = PTR_ERR(filp);
if (err)
*err = rc;
filp = NULL;
}
return (filp);
}
#define spl_filp_close(f) filp_close(f, NULL)
#define spl_filp_poff(f) (&(f)->f_pos)
#define spl_filp_write(fp, b, s, p) (fp)->f_op->write((fp), (b), (s), p)
static inline int
spl_filp_fallocate(struct file *fp, int mode, loff_t offset, loff_t len)
{
int error = -EOPNOTSUPP;
#ifdef HAVE_FILE_FALLOCATE
if (fp->f_op->fallocate)
error = fp->f_op->fallocate(fp, mode, offset, len);
#else
#ifdef HAVE_INODE_FALLOCATE
if (fp->f_dentry && fp->f_dentry->d_inode &&
fp->f_dentry->d_inode->i_op->fallocate)
error = fp->f_dentry->d_inode->i_op->fallocate(
fp->f_dentry->d_inode, mode, offset, len);
#endif /* HAVE_INODE_FALLOCATE */
#endif /* HAVE_FILE_FALLOCATE */
return (error);
}
static inline ssize_t
spl_kernel_write(struct file *file, const void *buf, size_t count, loff_t *pos)
{
#if defined(HAVE_KERNEL_WRITE_PPOS)
return (kernel_write(file, buf, count, pos));
#else
mm_segment_t saved_fs;
ssize_t ret;
saved_fs = get_fs();
set_fs(get_ds());
ret = vfs_write(file, (__force const char __user *)buf, count, pos);
set_fs(saved_fs);
return (ret);
#endif
}
static inline ssize_t
spl_kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
{
#if defined(HAVE_KERNEL_READ_PPOS)
return (kernel_read(file, buf, count, pos));
#else
mm_segment_t saved_fs;
ssize_t ret;
saved_fs = get_fs();
set_fs(get_ds());
ret = vfs_read(file, (void __user *)buf, count, pos);
set_fs(saved_fs);
return (ret);
#endif
}
#ifdef HAVE_2ARGS_VFS_FSYNC
#define spl_filp_fsync(fp, sync) vfs_fsync(fp, sync)
#else
#define spl_filp_fsync(fp, sync) vfs_fsync(fp, (fp)->f_dentry, sync)
#endif /* HAVE_2ARGS_VFS_FSYNC */
#ifdef HAVE_INODE_LOCK_SHARED
#define spl_inode_lock(ip) inode_lock(ip)
#define spl_inode_unlock(ip) inode_unlock(ip)
#define spl_inode_lock_shared(ip) inode_lock_shared(ip)
#define spl_inode_unlock_shared(ip) inode_unlock_shared(ip)
#define spl_inode_trylock(ip) inode_trylock(ip)
#define spl_inode_trylock_shared(ip) inode_trylock_shared(ip)
#define spl_inode_is_locked(ip) inode_is_locked(ip)
#define spl_inode_lock_nested(ip, s) inode_lock_nested(ip, s)
#else
#define spl_inode_lock(ip) mutex_lock(&(ip)->i_mutex)
#define spl_inode_unlock(ip) mutex_unlock(&(ip)->i_mutex)
#define spl_inode_lock_shared(ip) mutex_lock(&(ip)->i_mutex)
#define spl_inode_unlock_shared(ip) mutex_unlock(&(ip)->i_mutex)
#define spl_inode_trylock(ip) mutex_trylock(&(ip)->i_mutex)
#define spl_inode_trylock_shared(ip) mutex_trylock(&(ip)->i_mutex)
#define spl_inode_is_locked(ip) mutex_is_locked(&(ip)->i_mutex)
#define spl_inode_lock_nested(ip, s) mutex_lock_nested(&(ip)->i_mutex, s)
#endif
#endif /* SPL_FILE_COMPAT_H */

View File

@ -1,50 +0,0 @@
/*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_LIST_COMPAT_H
#define _SPL_LIST_COMPAT_H
#include <linux/list.h>
#ifndef list_for_each_entry_safe_reverse
/*
* list_for_each_entry_safe_reverse
* @pos: the type * to use as a loop cursor.
* @n: another type * to use as temporary storage
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*
* Iterate backwards over list of given type, safe against removal
* of list entry.
*/
#define list_for_each_entry_safe_reverse(pos, n, head, member) \
for (pos = list_entry((head)->prev, typeof(*pos), member), \
n = list_entry(pos->member.prev, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.prev, typeof(*n), member))
#endif /* list_for_each_entry_safe_reverse */
#endif /* SPL_LIST_COMPAT_H */

View File

@ -1,33 +0,0 @@
/*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_MATH64_COMPAT_H
#define _SPL_MATH64_COMPAT_H
#ifndef abs64
/* CSTYLED */
#define abs64(x) ({ uint64_t t = (x) >> 63; ((x) ^ t) - t; })
#endif
#endif /* _SPL_MATH64_COMPAT_H */

View File

@ -1,35 +0,0 @@
/*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_PROC_COMPAT_H
#define _SPL_PROC_COMPAT_H
#include <linux/proc_fs.h>
extern struct proc_dir_entry *proc_spl_kstat;
int spl_proc_init(void);
void spl_proc_fini(void);
#endif /* SPL_PROC_COMPAT_H */

View File

@ -1,68 +0,0 @@
/*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_RWSEM_COMPAT_H
#define _SPL_RWSEM_COMPAT_H
#include <linux/rwsem.h>
#if defined(CONFIG_PREEMPT_RT_FULL)
#define SPL_RWSEM_SINGLE_READER_VALUE (1)
#define SPL_RWSEM_SINGLE_WRITER_VALUE (0)
#elif defined(CONFIG_RWSEM_GENERIC_SPINLOCK)
#define SPL_RWSEM_SINGLE_READER_VALUE (1)
#define SPL_RWSEM_SINGLE_WRITER_VALUE (-1)
#else
#define SPL_RWSEM_SINGLE_READER_VALUE (RWSEM_ACTIVE_READ_BIAS)
#define SPL_RWSEM_SINGLE_WRITER_VALUE (RWSEM_ACTIVE_WRITE_BIAS)
#endif
/* Linux 3.16 changed activity to count for rwsem-spinlock */
#if defined(CONFIG_PREEMPT_RT_FULL)
#define RWSEM_COUNT(sem) sem->read_depth
#elif defined(HAVE_RWSEM_ACTIVITY)
#define RWSEM_COUNT(sem) sem->activity
/* Linux 4.8 changed count to an atomic_long_t for !rwsem-spinlock */
#elif defined(HAVE_RWSEM_ATOMIC_LONG_COUNT)
#define RWSEM_COUNT(sem) atomic_long_read(&(sem)->count)
#else
#define RWSEM_COUNT(sem) sem->count
#endif
int rwsem_tryupgrade(struct rw_semaphore *rwsem);
#if defined(RWSEM_SPINLOCK_IS_RAW)
#define spl_rwsem_lock_irqsave(lk, fl) raw_spin_lock_irqsave(lk, fl)
#define spl_rwsem_unlock_irqrestore(lk, fl) \
raw_spin_unlock_irqrestore(lk, fl)
#define spl_rwsem_trylock_irqsave(lk, fl) raw_spin_trylock_irqsave(lk, fl)
#else
#define spl_rwsem_lock_irqsave(lk, fl) spin_lock_irqsave(lk, fl)
#define spl_rwsem_unlock_irqrestore(lk, fl) spin_unlock_irqrestore(lk, fl)
#define spl_rwsem_trylock_irqsave(lk, fl) spin_trylock_irqsave(lk, fl)
#endif /* RWSEM_SPINLOCK_IS_RAW */
#define spl_rwsem_is_locked(rwsem) rwsem_is_locked(rwsem)
#endif /* _SPL_RWSEM_COMPAT_H */

View File

@ -1,37 +0,0 @@
/*
* Copyright (C) 2011 Lawrence Livermore National Security, LLC.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_ZLIB_COMPAT_H
#define _SPL_ZLIB_COMPAT_H
#include <linux/zlib.h>
#ifdef HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
#define spl_zlib_deflate_workspacesize(wb, ml) \
zlib_deflate_workspacesize(wb, ml)
#else
#define spl_zlib_deflate_workspacesize(wb, ml) \
zlib_deflate_workspacesize()
#endif /* HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE */
#endif /* SPL_ZLIB_COMPAT_H */

View File

@ -1,14 +0,0 @@
COMMON_H =
KERNEL_H = \
$(top_srcdir)/include/rpc/types.h \
$(top_srcdir)/include/rpc/xdr.h
USER_H =
EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
if CONFIG_KERNEL
kerneldir = @prefix@/src/spl-$(VERSION)/include/rpc
kernel_HEADERS = $(KERNEL_H)
endif

View File

@ -1,30 +0,0 @@
/*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_RPC_TYPES_H
#define _SPL_RPC_TYPES_H
typedef int bool_t;
#endif /* SPL_RPC_TYPES_H */

View File

@ -1,13 +0,0 @@
COMMON_H =
KERNEL_H = \
$(top_srcdir)/include/sharefs/share.h
USER_H =
EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
if CONFIG_KERNEL
kerneldir = @prefix@/src/spl-$(VERSION)/include/sharefs
kernel_HEADERS = $(KERNEL_H)
endif

View File

@ -1,28 +0,0 @@
/*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_SHARE_H
#define _SPL_SHARE_H
#endif /* SPL_SHARE_H */

View File

@ -1,45 +0,0 @@
/*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _DEBUG_CTL_H
#define _DEBUG_CTL_H
/*
* Contains shared definitions which both the user space
* and kernel space portions of splat must agree on.
*/
typedef struct spl_debug_header {
int ph_len;
int ph_flags;
int ph_subsys;
int ph_mask;
int ph_cpu_id;
int ph_sec;
long ph_usec;
int ph_stack;
int ph_pid;
int ph_line_num;
} spl_debug_header_t;
#endif /* _DEBUG_CTL_H */

View File

@ -23,7 +23,8 @@
#define _SPL_RPC_XDR_H
#include <sys/types.h>
#include <rpc/types.h>
typedef int bool_t;
/*
* XDR enums and types.

79
include/spl/sys/atomic.h Normal file
View File

@ -0,0 +1,79 @@
/*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
* For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The SPL is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_ATOMIC_H
#define _SPL_ATOMIC_H
#include <linux/module.h>
#include <linux/spinlock.h>
#include <sys/types.h>
/*
* Map the atomic_* functions to the Linux counterparts. This relies on the
* fact that the atomic types are internally really a uint32 or uint64. If
* this were to change an alternate approach would be needed.
*
* N.B. Due to the limitations of the original API atomicity is not strictly
* preserved when using the 64-bit functions on a 32-bit system. In order
* to support this all consumers would need to be updated to use the Linux
* provided atomic_t and atomic64_t types.
*/
#define atomic_inc_32(v) atomic_inc((atomic_t *)(v))
#define atomic_dec_32(v) atomic_dec((atomic_t *)(v))
#define atomic_add_32(v, i) atomic_add((i), (atomic_t *)(v))
#define atomic_sub_32(v, i) atomic_sub((i), (atomic_t *)(v))
#define atomic_inc_32_nv(v) atomic_inc_return((atomic_t *)(v))
#define atomic_dec_32_nv(v) atomic_dec_return((atomic_t *)(v))
#define atomic_add_32_nv(v, i) atomic_add_return((i), (atomic_t *)(v))
#define atomic_sub_32_nv(v, i) atomic_sub_return((i), (atomic_t *)(v))
#define atomic_cas_32(v, x, y) atomic_cmpxchg((atomic_t *)(v), x, y)
#define atomic_swap_32(v, x) atomic_xchg((atomic_t *)(v), x)
#define atomic_inc_64(v) atomic64_inc((atomic64_t *)(v))
#define atomic_dec_64(v) atomic64_dec((atomic64_t *)(v))
#define atomic_add_64(v, i) atomic64_add((i), (atomic64_t *)(v))
#define atomic_sub_64(v, i) atomic64_sub((i), (atomic64_t *)(v))
#define atomic_inc_64_nv(v) atomic64_inc_return((atomic64_t *)(v))
#define atomic_dec_64_nv(v) atomic64_dec_return((atomic64_t *)(v))
#define atomic_add_64_nv(v, i) atomic64_add_return((i), (atomic64_t *)(v))
#define atomic_sub_64_nv(v, i) atomic64_sub_return((i), (atomic64_t *)(v))
#define atomic_cas_64(v, x, y) atomic64_cmpxchg((atomic64_t *)(v), x, y)
#define atomic_swap_64(v, x) atomic64_xchg((atomic64_t *)(v), x)
#ifdef _LP64
static __inline__ void *
atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
{
return ((void *)atomic_cas_64((volatile uint64_t *)target,
(uint64_t)cmp, (uint64_t)newval));
}
#else /* _LP64 */
static __inline__ void *
atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
{
return ((void *)atomic_cas_32((volatile uint32_t *)target,
(uint32_t)cmp, (uint32_t)newval));
}
#endif /* _LP64 */
#endif /* _SPL_ATOMIC_H */

View File

@ -28,6 +28,11 @@
#include <asm/byteorder.h>
#include <sys/isa_defs.h>
#define BSWAP_8(x) ((x) & 0xff)
#define BSWAP_16(x) ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8))
#define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16))
#define BSWAP_64(x) ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32))
#define LE_16(x) cpu_to_le16(x)
#define LE_32(x) cpu_to_le32(x)
#define LE_64(x) cpu_to_le64(x)

View File

@ -25,7 +25,7 @@
#ifndef _SPL_CMN_ERR_H
#define _SPL_CMN_ERR_H
#include <sys/varargs.h>
#include <stdarg.h>
#define CE_CONT 0 /* continuation */
#define CE_NOTE 1 /* notice */
@ -34,8 +34,8 @@
#define CE_IGNORE 4 /* print nothing */
extern void cmn_err(int, const char *, ...);
extern void vcmn_err(int, const char *, __va_list);
extern void vpanic(const char *, __va_list);
extern void vcmn_err(int, const char *, va_list);
extern void vpanic(const char *, va_list);
#define fm_panic panic

View File

@ -26,11 +26,10 @@
#define _SPL_CONDVAR_H
#include <linux/module.h>
#include <linux/wait_compat.h>
#include <linux/delay_compat.h>
#include <sys/kmem.h>
#include <sys/mutex.h>
#include <sys/callo.h>
#include <sys/wait.h>
/*
* The kcondvar_t struct is protected by mutex taken externally before

View File

@ -26,6 +26,7 @@
#define _SPL_CRED_H
#include <linux/module.h>
#include <linux/cred.h>
#include <sys/types.h>
#include <sys/vfs.h>

View File

@ -25,7 +25,28 @@
#ifndef _SPL_FILE_H
#define _SPL_FILE_H
#define FIGNORECASE 0x00080000
#define FKIOCTL 0x80000000
#define FIGNORECASE 0x00080000
#define FKIOCTL 0x80000000
#define ED_CASE_CONFLICT 0x10
#ifdef HAVE_INODE_LOCK_SHARED
#define spl_inode_lock(ip) inode_lock(ip)
#define spl_inode_unlock(ip) inode_unlock(ip)
#define spl_inode_lock_shared(ip) inode_lock_shared(ip)
#define spl_inode_unlock_shared(ip) inode_unlock_shared(ip)
#define spl_inode_trylock(ip) inode_trylock(ip)
#define spl_inode_trylock_shared(ip) inode_trylock_shared(ip)
#define spl_inode_is_locked(ip) inode_is_locked(ip)
#define spl_inode_lock_nested(ip, s) inode_lock_nested(ip, s)
#else
#define spl_inode_lock(ip) mutex_lock(&(ip)->i_mutex)
#define spl_inode_unlock(ip) mutex_unlock(&(ip)->i_mutex)
#define spl_inode_lock_shared(ip) mutex_lock(&(ip)->i_mutex)
#define spl_inode_unlock_shared(ip) mutex_unlock(&(ip)->i_mutex)
#define spl_inode_trylock(ip) mutex_trylock(&(ip)->i_mutex)
#define spl_inode_trylock_shared(ip) mutex_trylock(&(ip)->i_mutex)
#define spl_inode_is_locked(ip) mutex_is_locked(&(ip)->i_mutex)
#define spl_inode_lock_nested(ip, s) mutex_lock_nested(&(ip)->i_mutex, s)
#endif
#endif /* SPL_FILE_H */

View File

@ -26,11 +26,11 @@
#define _SPL_KSTAT_H
#include <linux/module.h>
#include <linux/proc_compat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/kmem.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#define KSTAT_STRLEN 255
#define KSTAT_RAW_MAX (128*1024)

View File

@ -72,10 +72,6 @@ list_link_init(list_node_t *node)
static inline void
list_create(list_t *list, size_t size, size_t offset)
{
ASSERT(list);
ASSERT(size > 0);
ASSERT(size >= offset + sizeof (list_node_t));
list->list_size = size;
list->list_offset = offset;
INIT_LIST_HEAD(&list->list_head);
@ -84,9 +80,6 @@ list_create(list_t *list, size_t size, size_t offset)
static inline void
list_destroy(list_t *list)
{
ASSERT(list);
ASSERT(list_is_empty(list));
list_del(&list->list_head);
}
@ -123,7 +116,6 @@ list_insert_before(list_t *list, void *object, void *nobject)
static inline void
list_remove(list_t *list, void *object)
{
ASSERT(!list_is_empty(list));
list_del(list_d2l(list, object));
}
@ -206,9 +198,6 @@ spl_list_move_tail(list_t *dst, list_t *src)
static inline void
list_link_replace(list_node_t *old_node, list_node_t *new_node)
{
ASSERT(list_link_active(old_node));
ASSERT(!list_link_active(new_node));
new_node->next = old_node->next;
new_node->prev = old_node->prev;
old_node->prev->next = new_node;

View File

@ -27,7 +27,6 @@
#include <sys/types.h>
#include <linux/mutex.h>
#include <linux/compiler_compat.h>
#include <linux/lockdep.h>
typedef enum {

View File

@ -25,4 +25,11 @@
#ifndef _SPL_PROC_H
#define _SPL_PROC_H
#include <linux/proc_fs.h>
extern struct proc_dir_entry *proc_spl_kstat;
int spl_proc_init(void);
void spl_proc_fini(void);
#endif /* SPL_PROC_H */

View File

@ -27,7 +27,43 @@
#include <sys/types.h>
#include <linux/rwsem.h>
#include <linux/rwsem_compat.h>
/* Linux kernel compatibility */
#if defined(CONFIG_PREEMPT_RT_FULL)
#define SPL_RWSEM_SINGLE_READER_VALUE (1)
#define SPL_RWSEM_SINGLE_WRITER_VALUE (0)
#elif defined(CONFIG_RWSEM_GENERIC_SPINLOCK)
#define SPL_RWSEM_SINGLE_READER_VALUE (1)
#define SPL_RWSEM_SINGLE_WRITER_VALUE (-1)
#else
#define SPL_RWSEM_SINGLE_READER_VALUE (RWSEM_ACTIVE_READ_BIAS)
#define SPL_RWSEM_SINGLE_WRITER_VALUE (RWSEM_ACTIVE_WRITE_BIAS)
#endif
/* Linux 3.16 changed activity to count for rwsem-spinlock */
#if defined(CONFIG_PREEMPT_RT_FULL)
#define RWSEM_COUNT(sem) sem->read_depth
#elif defined(HAVE_RWSEM_ACTIVITY)
#define RWSEM_COUNT(sem) sem->activity
/* Linux 4.8 changed count to an atomic_long_t for !rwsem-spinlock */
#elif defined(HAVE_RWSEM_ATOMIC_LONG_COUNT)
#define RWSEM_COUNT(sem) atomic_long_read(&(sem)->count)
#else
#define RWSEM_COUNT(sem) sem->count
#endif
#if defined(RWSEM_SPINLOCK_IS_RAW)
#define spl_rwsem_lock_irqsave(lk, fl) raw_spin_lock_irqsave(lk, fl)
#define spl_rwsem_unlock_irqrestore(lk, fl) \
raw_spin_unlock_irqrestore(lk, fl)
#define spl_rwsem_trylock_irqsave(lk, fl) raw_spin_trylock_irqsave(lk, fl)
#else
#define spl_rwsem_lock_irqsave(lk, fl) spin_lock_irqsave(lk, fl)
#define spl_rwsem_unlock_irqrestore(lk, fl) spin_unlock_irqrestore(lk, fl)
#define spl_rwsem_trylock_irqsave(lk, fl) spin_trylock_irqsave(lk, fl)
#endif /* RWSEM_SPINLOCK_IS_RAW */
#define spl_rwsem_is_locked(rwsem) rwsem_is_locked(rwsem)
typedef enum {
RW_DRIVER = 2,
@ -232,5 +268,6 @@ RW_LOCK_HELD(krwlock_t *rwp)
int spl_rw_init(void);
void spl_rw_fini(void);
int rwsem_tryupgrade(struct rw_semaphore *rwsem);
#endif /* _SPL_RWLOCK_H */

View File

@ -22,8 +22,8 @@
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_MM_COMPAT_H
#define _SPL_MM_COMPAT_H
#ifndef _SPL_SHRINKER_H
#define _SPL_SHRINKER_H
#include <linux/mm.h>
#include <linux/fs.h>
@ -206,4 +206,4 @@ typedef int spl_shrinker_t;
#define SHRINK_STOP (-1)
#endif
#endif /* SPL_MM_COMPAT_H */
#endif /* SPL_SHRINKER_H */

View File

@ -1,7 +1,6 @@
/*
* Copyright (C) 2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2018 Lawrence Livermore National Security, LLC.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
@ -20,10 +19,13 @@
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SPL_SYS_STRINGS_H
#define _SPL_SYS_STRINGS_H
#ifndef _SPL_IDMAP_H
#define _SPL_IDMAP_H
#include <linux/string.h>
#define IDMAP_WK_CREATOR_OWNER_UID 2147483648U
#define bzero(ptr, size) memset(ptr, 0, size)
#define bcopy(src, dest, size) memmove(dest, src, size)
#define bcmp(src, dest, size) memcmp((src), (dest), (size_t)(size))
#endif /* SPL_IDMAP_H */
#endif /* _SPL_SYS_STRINGS_H */

View File

@ -27,7 +27,6 @@
#include <sys/cred.h>
#include <sys/uio.h>
#include <sys/sunldi.h>
#include <sys/mutex.h>
#include <sys/u8_textprep.h>
#include <sys/vnode.h>

View File

@ -29,7 +29,6 @@
#include <linux/sched.h>
#include <linux/cpumask.h>
#include <sys/debug.h>
#include <sys/varargs.h>
#include <sys/zone.h>
#include <sys/signal.h>
#include <asm/page.h>
@ -66,11 +65,10 @@
#define UINT64_MIN ULLONG_MIN
#define NBBY 8
#define ENOTSUP EOPNOTSUPP
#define MAXMSGLEN 256
#define MAXNAMELEN 256
#define MAXPATHLEN PATH_MAX
#define MAXPATHLEN 4096
#define MAXOFFSET_T LLONG_MAX
#define MAXBSIZE 8192
#define DEV_BSIZE 512
@ -117,19 +115,6 @@
#define PAGESHIFT PAGE_SHIFT
#endif
/* from Solaris sys/byteorder.h */
#define BSWAP_8(x) ((x) & 0xff)
#define BSWAP_16(x) ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8))
#define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16))
#define BSWAP_64(x) ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32))
/*
* Map some simple functions.
*/
#define bzero(ptr, size) memset(ptr, 0, size)
#define bcopy(src, dest, size) memmove(dest, src, size)
#define bcmp(src, dest, size) memcmp((src), (dest), (size_t)(size))
/* Dtrace probes do not exist in the linux kernel */
#ifdef DTRACE_PROBE
#undef DTRACE_PROBE

View File

@ -30,10 +30,10 @@
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/kthread.h>
#include <linux/wait_compat.h>
#include <sys/types.h>
#include <sys/thread.h>
#include <sys/rwlock.h>
#include <sys/wait.h>
#define TASKQ_NAMELEN 31

View File

@ -62,6 +62,8 @@ extern kthread_t *__thread_create(caddr_t stk, size_t stksize,
int state, pri_t pri);
extern void __thread_exit(void);
extern struct task_struct *spl_kthread_create(int (*func)(void *),
void *data, const char namefmt[], ...);
void *data, const char namefmt[], ...);
extern proc_t p0;
#endif /* _SPL_THREAD_H */

View File

@ -26,7 +26,9 @@
#define _SPL_TIMER_H
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/time.h>
#include <linux/timer.h>
#define lbolt ((clock_t)jiffies)
@ -51,6 +53,20 @@
#define delay(ticks) schedule_timeout_uninterruptible(ticks)
/* usleep_range() introduced in 2.6.36 */
#ifndef HAVE_USLEEP_RANGE
static inline void
usleep_range(unsigned long min, unsigned long max)
{
unsigned int min_ms = min / USEC_PER_MSEC;
if (min >= MAX_UDELAY_MS)
msleep(min_ms);
else
udelay(min);
}
#endif /* HAVE_USLEEP_RANGE */
#define SEC_TO_TICK(sec) ((sec) * HZ)
#define MSEC_TO_TICK(ms) msecs_to_jiffies(ms)
#define USEC_TO_TICK(us) usecs_to_jiffies(us)

View File

@ -26,7 +26,6 @@
#define _SPL_TYPES_H
#include <linux/types.h>
#include <sys/sysmacros.h>
#ifndef ULLONG_MAX
#define ULLONG_MAX (~0ULL)
@ -36,33 +35,36 @@
#define LLONG_MAX ((long long)(~0ULL>>1))
#endif
typedef enum { B_FALSE = 0, B_TRUE = 1 } boolean_t;
typedef unsigned long intptr_t;
typedef unsigned long ulong_t;
typedef unsigned int uint_t;
typedef unsigned char uchar_t;
typedef unsigned long long u_longlong_t;
typedef unsigned long long u_offset_t;
typedef unsigned long long rlim64_t;
typedef long long longlong_t;
typedef long long offset_t;
typedef struct task_struct kthread_t;
typedef struct task_struct proc_t;
typedef short pri_t;
typedef struct timespec timestruc_t; /* definition per SVr4 */
typedef struct timespec timespec_t;
typedef longlong_t hrtime_t;
typedef unsigned short ushort_t;
typedef u_longlong_t len_t;
typedef longlong_t diskaddr_t;
typedef ushort_t o_mode_t;
typedef uint_t major_t;
typedef uint_t minor_t;
typedef ulong_t pgcnt_t;
typedef long spgcnt_t;
typedef short index_t;
typedef int id_t;
typedef enum {
B_FALSE = 0,
B_TRUE = 1
} boolean_t;
extern proc_t p0;
typedef unsigned char uchar_t;
typedef unsigned short ushort_t;
typedef unsigned int uint_t;
typedef unsigned long ulong_t;
typedef unsigned long long u_longlong_t;
typedef long long longlong_t;
typedef unsigned long intptr_t;
typedef unsigned long long rlim64_t;
typedef struct task_struct kthread_t;
typedef struct task_struct proc_t;
typedef struct timespec timestruc_t;
typedef struct timespec timespec_t;
typedef longlong_t hrtime_t;
typedef int id_t;
typedef short pri_t;
typedef short index_t;
typedef longlong_t offset_t;
typedef u_longlong_t u_offset_t;
typedef ulong_t pgcnt_t;
typedef int major_t;
typedef int minor_t;
#endif /* _SPL_TYPES_H */

View File

@ -25,7 +25,6 @@
#ifndef _SPL_TYPES32_H
#define _SPL_TYPES32_H
#include <sys/int_types.h>
#include <sys/types.h>
typedef uint32_t caddr32_t;

View File

@ -41,7 +41,6 @@
#include <sys/time.h>
#include <sys/uio.h>
#include <sys/user.h>
#include <sys/sunldi.h>
/*
* Prior to linux-2.6.33 only O_DSYNC semantics were implemented and

Some files were not shown because too many files have changed in this diff Show More