mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-27 03:19:35 +03:00
2.6.27+ portability changes
- Added SPL_AC_3ARGS_ON_EACH_CPU configure check to determine if the older 4 argument version of on_each_cpu() should be used or the new 3 argument version. The retry argument was dropped in the new API which was never used anyway. - Updated work queue compatibility wrappers. The old way this worked was to pass a data point when initialized the workqueue. The new API assumed the work item is embedding in a structure and we us container_of() to find that data pointer. - Updated skc->skc_flags to be an unsigned long which is now type checked in the bit operations. This silences the warnings. - Updated autogen products and splat tests accordingly
This commit is contained in:
parent
f220894e1f
commit
31a033ecd4
@ -686,3 +686,22 @@ AC_DEFUN([SPL_AC_DIV64_64], [
|
|||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl #
|
||||||
|
dnl # 2.6.27 API change,
|
||||||
|
dnl # on_each_cpu() uses 3 args, no 'retry' argument
|
||||||
|
dnl #
|
||||||
|
AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
|
||||||
|
AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
|
||||||
|
SPL_LINUX_TRY_COMPILE([
|
||||||
|
#include <linux/smp.h>
|
||||||
|
],[
|
||||||
|
on_each_cpu(NULL, NULL, 0);
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
|
||||||
|
[on_each_cpu wants 3 args])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
])
|
||||||
|
])
|
||||||
|
61
configure
vendored
61
configure
vendored
@ -20407,6 +20407,67 @@ cat >>confdefs.h <<\_ACEOF
|
|||||||
_ACEOF
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "$as_me: failed program was:" >&5
|
||||||
|
sed 's/^/| /' conftest.$ac_ext >&5
|
||||||
|
|
||||||
|
|
||||||
|
echo "$as_me:$LINENO: result: no" >&5
|
||||||
|
echo "${ECHO_T}no" >&6
|
||||||
|
|
||||||
|
fi
|
||||||
|
rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "$as_me:$LINENO: checking whether on_each_cpu() wants 3 args" >&5
|
||||||
|
echo $ECHO_N "checking whether on_each_cpu() wants 3 args... $ECHO_C" >&6
|
||||||
|
|
||||||
|
|
||||||
|
cat >conftest.c <<_ACEOF
|
||||||
|
/* confdefs.h. */
|
||||||
|
_ACEOF
|
||||||
|
cat confdefs.h >>conftest.$ac_ext
|
||||||
|
cat >>conftest.$ac_ext <<_ACEOF
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
|
||||||
|
#include <linux/smp.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
|
||||||
|
on_each_cpu(NULL, NULL, 0);
|
||||||
|
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
rm -f build/conftest.o build/conftest.mod.c build/conftest.ko build/Makefile
|
||||||
|
echo "obj-m := conftest.o" >build/Makefile
|
||||||
|
if { ac_try='cp conftest.c build && make modules CC="$CC" LINUXINCLUDE="-Iinclude -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
|
||||||
|
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||||
|
(eval $ac_try) 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
|
||||||
|
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||||
|
(eval $ac_try) 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); }; }; then
|
||||||
|
|
||||||
|
echo "$as_me:$LINENO: result: yes" >&5
|
||||||
|
echo "${ECHO_T}yes" >&6
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define HAVE_3ARGS_ON_EACH_CPU 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "$as_me: failed program was:" >&5
|
echo "$as_me: failed program was:" >&5
|
||||||
sed 's/^/| /' conftest.$ac_ext >&5
|
sed 's/^/| /' conftest.$ac_ext >&5
|
||||||
|
@ -68,6 +68,7 @@ SPL_AC_KMALLOC_NODE
|
|||||||
SPL_AC_MONOTONIC_CLOCK
|
SPL_AC_MONOTONIC_CLOCK
|
||||||
SPL_AC_INODE_I_MUTEX
|
SPL_AC_INODE_I_MUTEX
|
||||||
SPL_AC_DIV64_64
|
SPL_AC_DIV64_64
|
||||||
|
SPL_AC_3ARGS_ON_EACH_CPU
|
||||||
|
|
||||||
TOPDIR=`/bin/pwd`
|
TOPDIR=`/bin/pwd`
|
||||||
|
|
||||||
|
16
include/linux/smp_compat.h
Normal file
16
include/linux/smp_compat.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef _SPL_SMP_COMPAT_H
|
||||||
|
#define _SPL_SMP_COMPAT_H
|
||||||
|
|
||||||
|
#include <linux/smp.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_3ARGS_ON_EACH_CPU
|
||||||
|
|
||||||
|
#define spl_on_each_cpu(func,info,wait) on_each_cpu(func,info,wait)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define spl_on_each_cpu(func,info,wait) on_each_cpu(func,info,0,wait)
|
||||||
|
|
||||||
|
#endif /* HAVE_3ARGS_ON_EACH_CPU */
|
||||||
|
|
||||||
|
#endif /* _SPL_SMP_COMPAT_H */
|
25
include/linux/workqueue_compat.h
Normal file
25
include/linux/workqueue_compat.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef _SPL_WORKQUEUE_COMPAT_H
|
||||||
|
#define _SPL_WORKQUEUE_COMPAT_H
|
||||||
|
|
||||||
|
#include <linux/workqueue.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_3ARGS_INIT_WORK
|
||||||
|
|
||||||
|
#define delayed_work work_struct
|
||||||
|
|
||||||
|
#define spl_init_work(wq, cb, d) INIT_WORK((wq), (void *)(cb), \
|
||||||
|
(void *)(d))
|
||||||
|
#define spl_init_delayed_work(wq,cb,d) INIT_WORK((wq), (void *)(cb), \
|
||||||
|
(void *)(d))
|
||||||
|
#define spl_get_work_data(d, t, f) (t *)(d)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define spl_init_work(wq, cb, d) INIT_WORK((wq), (void *)(cb));
|
||||||
|
#define spl_init_delayed_work(wq,cb,d) INIT_DELAYED_WORK((wq), (void *)(cb));
|
||||||
|
#define spl_get_work_data(d, t, f) (t *)container_of(d, t, f)
|
||||||
|
|
||||||
|
#endif /* HAVE_3ARGS_INIT_WORK */
|
||||||
|
|
||||||
|
#endif /* _SPL_WORKQUEUE_COMPAT_H */
|
@ -45,7 +45,6 @@ extern "C" {
|
|||||||
#include <asm/atomic_compat.h>
|
#include <asm/atomic_compat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/debug.h>
|
#include <sys/debug.h>
|
||||||
#include <sys/workqueue.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Memory allocation interfaces
|
* Memory allocation interfaces
|
||||||
@ -286,7 +285,7 @@ typedef struct spl_kmem_cache {
|
|||||||
spl_kmem_reclaim_t skc_reclaim; /* Reclaimator */
|
spl_kmem_reclaim_t skc_reclaim; /* Reclaimator */
|
||||||
void *skc_private; /* Private data */
|
void *skc_private; /* Private data */
|
||||||
void *skc_vmp; /* Unused */
|
void *skc_vmp; /* Unused */
|
||||||
uint32_t skc_flags; /* Flags */
|
unsigned long skc_flags; /* Flags */
|
||||||
uint32_t skc_obj_size; /* Object size */
|
uint32_t skc_obj_size; /* Object size */
|
||||||
uint32_t skc_obj_align; /* Object alignment */
|
uint32_t skc_obj_align; /* Object alignment */
|
||||||
uint32_t skc_slab_objs; /* Objects per slab */
|
uint32_t skc_slab_objs; /* Objects per slab */
|
||||||
|
@ -14,6 +14,8 @@ extern "C" {
|
|||||||
#include <linux/list_compat.h>
|
#include <linux/list_compat.h>
|
||||||
#include <linux/time_compat.h>
|
#include <linux/time_compat.h>
|
||||||
#include <linux/bitops_compat.h>
|
#include <linux/bitops_compat.h>
|
||||||
|
#include <linux/smp_compat.h>
|
||||||
|
#include <linux/workqueue_compat.h>
|
||||||
|
|
||||||
#ifndef HAVE_UINTPTR_T
|
#ifndef HAVE_UINTPTR_T
|
||||||
typedef unsigned long uintptr_t;
|
typedef unsigned long uintptr_t;
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the SPL: Solaris Porting Layer.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008 Lawrence Livermore National Security, LLC.
|
|
||||||
* Produced at Lawrence Livermore National Laboratory
|
|
||||||
* Written by:
|
|
||||||
* Brian Behlendorf <behlendorf1@llnl.gov>,
|
|
||||||
* Herb Wartens <wartens2@llnl.gov>,
|
|
||||||
* Jim Garlick <garlick@llnl.gov>
|
|
||||||
* UCRL-CODE-235197
|
|
||||||
*
|
|
||||||
* This 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.
|
|
||||||
*
|
|
||||||
* This 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 this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SPL_WORKQUEUE_H
|
|
||||||
#define _SPL_WORKQUEUE_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <linux/workqueue.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_3ARGS_INIT_WORK
|
|
||||||
|
|
||||||
#define delayed_work work_struct
|
|
||||||
|
|
||||||
#define spl_init_work(wq, cb, d) INIT_WORK((wq), (void *)(cb), \
|
|
||||||
(void *)(d))
|
|
||||||
#define spl_init_delayed_work(wq,cb,d) INIT_WORK((wq), (void *)(cb), \
|
|
||||||
(void *)(d))
|
|
||||||
#define spl_get_work_data(d, t, f) (t *)(d)
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define spl_init_work(wq, cb, d) INIT_WORK((wq), (void *)(cb));
|
|
||||||
#define spl_init_delayed_work(wq,cb,d) INIT_DELAYED_WORK((wq), (void *)(cb));
|
|
||||||
#define spl_get_work_data(d, t, f) (t *)container_of(d, t, f)
|
|
||||||
|
|
||||||
#endif /* HAVE_3ARGS_INIT_WORK */
|
|
||||||
|
|
||||||
#endif /* _SPL_WORKQUEUE_H */
|
|
@ -783,7 +783,7 @@ spl_cache_age(void *data)
|
|||||||
spl_get_work_data(data, spl_kmem_cache_t, skc_work.work);
|
spl_get_work_data(data, spl_kmem_cache_t, skc_work.work);
|
||||||
|
|
||||||
ASSERT(skc->skc_magic == SKC_MAGIC);
|
ASSERT(skc->skc_magic == SKC_MAGIC);
|
||||||
on_each_cpu(spl_magazine_age, skc, 0, 1);
|
spl_on_each_cpu(spl_magazine_age, skc, 1);
|
||||||
spl_slab_reclaim(skc, 0);
|
spl_slab_reclaim(skc, 0);
|
||||||
|
|
||||||
if (!test_bit(KMC_BIT_DESTROY, &skc->skc_flags))
|
if (!test_bit(KMC_BIT_DESTROY, &skc->skc_flags))
|
||||||
@ -923,7 +923,7 @@ spl_magazine_create(spl_kmem_cache_t *skc)
|
|||||||
|
|
||||||
skc->skc_mag_size = spl_magazine_size(skc);
|
skc->skc_mag_size = spl_magazine_size(skc);
|
||||||
skc->skc_mag_refill = (skc->skc_mag_size + 1) / 2;
|
skc->skc_mag_refill = (skc->skc_mag_size + 1) / 2;
|
||||||
on_each_cpu(__spl_magazine_create, skc, 0, 1);
|
spl_on_each_cpu(__spl_magazine_create, skc, 1);
|
||||||
|
|
||||||
RETURN(0);
|
RETURN(0);
|
||||||
}
|
}
|
||||||
@ -945,7 +945,7 @@ static void
|
|||||||
spl_magazine_destroy(spl_kmem_cache_t *skc)
|
spl_magazine_destroy(spl_kmem_cache_t *skc)
|
||||||
{
|
{
|
||||||
ENTRY;
|
ENTRY;
|
||||||
on_each_cpu(__spl_magazine_destroy, skc, 0, 1);
|
spl_on_each_cpu(__spl_magazine_destroy, skc, 1);
|
||||||
EXIT;
|
EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,28 +59,26 @@ typedef struct mutex_priv {
|
|||||||
int mp_rc;
|
int mp_rc;
|
||||||
} mutex_priv_t;
|
} mutex_priv_t;
|
||||||
|
|
||||||
#ifdef HAVE_3ARGS_INIT_WORK
|
|
||||||
static void
|
static void
|
||||||
splat_mutex_test1_work(void *priv)
|
splat_mutex_test1_work(void *priv)
|
||||||
{
|
{
|
||||||
mutex_priv_t *mp = (mutex_priv_t *)priv;
|
mutex_priv_t *mp;
|
||||||
|
|
||||||
|
mp = spl_get_work_data(priv, mutex_priv_t, mp_work.work);
|
||||||
ASSERT(mp->mp_magic == SPLAT_MUTEX_TEST_MAGIC);
|
ASSERT(mp->mp_magic == SPLAT_MUTEX_TEST_MAGIC);
|
||||||
mp->mp_rc = 0;
|
mp->mp_rc = 0;
|
||||||
|
|
||||||
if (!mutex_tryenter(&mp->mp_mtx))
|
if (!mutex_tryenter(&mp->mp_mtx))
|
||||||
mp->mp_rc = -EBUSY;
|
mp->mp_rc = -EBUSY;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
splat_mutex_test1(struct file *file, void *arg)
|
splat_mutex_test1(struct file *file, void *arg)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
|
||||||
#ifdef HAVE_3ARGS_INIT_WORK
|
|
||||||
struct workqueue_struct *wq;
|
struct workqueue_struct *wq;
|
||||||
struct work_struct work;
|
struct work_struct work;
|
||||||
mutex_priv_t *mp;
|
mutex_priv_t *mp;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
mp = (mutex_priv_t *)kmalloc(sizeof(*mp), GFP_KERNEL);
|
mp = (mutex_priv_t *)kmalloc(sizeof(*mp), GFP_KERNEL);
|
||||||
if (mp == NULL)
|
if (mp == NULL)
|
||||||
@ -97,7 +95,7 @@ splat_mutex_test1(struct file *file, void *arg)
|
|||||||
|
|
||||||
mp->mp_magic = SPLAT_MUTEX_TEST_MAGIC;
|
mp->mp_magic = SPLAT_MUTEX_TEST_MAGIC;
|
||||||
mp->mp_file = file;
|
mp->mp_file = file;
|
||||||
INIT_WORK(&work, splat_mutex_test1_work, mp);
|
spl_init_work(&work, splat_mutex_test1_work, mp);
|
||||||
|
|
||||||
/* Schedule a work item which will try and aquire the mutex via
|
/* Schedule a work item which will try and aquire the mutex via
|
||||||
* mutex_tryenter() while its held. This should fail and the work
|
* mutex_tryenter() while its held. This should fail and the work
|
||||||
@ -143,17 +141,16 @@ out:
|
|||||||
destroy_workqueue(wq);
|
destroy_workqueue(wq);
|
||||||
out2:
|
out2:
|
||||||
kfree(mp);
|
kfree(mp);
|
||||||
#endif
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_3ARGS_INIT_WORK
|
|
||||||
static void
|
static void
|
||||||
splat_mutex_test2_work(void *priv)
|
splat_mutex_test2_work(void *priv)
|
||||||
{
|
{
|
||||||
mutex_priv_t *mp = (mutex_priv_t *)priv;
|
mutex_priv_t *mp;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
mp = spl_get_work_data(priv, mutex_priv_t, mp_work.work);
|
||||||
ASSERT(mp->mp_magic == SPLAT_MUTEX_TEST_MAGIC);
|
ASSERT(mp->mp_magic == SPLAT_MUTEX_TEST_MAGIC);
|
||||||
|
|
||||||
/* Read the value before sleeping and write it after we wake up to
|
/* Read the value before sleeping and write it after we wake up to
|
||||||
@ -165,16 +162,13 @@ splat_mutex_test2_work(void *priv)
|
|||||||
mp->mp_rc = rc + 1;
|
mp->mp_rc = rc + 1;
|
||||||
mutex_exit(&mp->mp_mtx);
|
mutex_exit(&mp->mp_mtx);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
splat_mutex_test2(struct file *file, void *arg)
|
splat_mutex_test2(struct file *file, void *arg)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
|
||||||
#ifdef HAVE_3ARGS_INIT_WORK
|
|
||||||
struct workqueue_struct *wq;
|
struct workqueue_struct *wq;
|
||||||
mutex_priv_t *mp;
|
mutex_priv_t *mp;
|
||||||
int i;
|
int i, rc = 0;
|
||||||
|
|
||||||
mp = (mutex_priv_t *)kmalloc(sizeof(*mp), GFP_KERNEL);
|
mp = (mutex_priv_t *)kmalloc(sizeof(*mp), GFP_KERNEL);
|
||||||
if (mp == NULL)
|
if (mp == NULL)
|
||||||
@ -200,7 +194,7 @@ splat_mutex_test2(struct file *file, void *arg)
|
|||||||
* critical region at the same time the system will panic. If the
|
* critical region at the same time the system will panic. If the
|
||||||
* mutex is implemented right this will never happy, that's a pass. */
|
* mutex is implemented right this will never happy, that's a pass. */
|
||||||
for (i = 0; i < SPLAT_MUTEX_TEST_COUNT; i++) {
|
for (i = 0; i < SPLAT_MUTEX_TEST_COUNT; i++) {
|
||||||
INIT_WORK(&(mp->mp_work[i]), splat_mutex_test2_work, mp);
|
spl_init_work(&(mp->mp_work[i]), splat_mutex_test2_work, mp);
|
||||||
|
|
||||||
if (!queue_work(wq, &(mp->mp_work[i]))) {
|
if (!queue_work(wq, &(mp->mp_work[i]))) {
|
||||||
splat_vprint(file, SPLAT_MUTEX_TEST2_NAME,
|
splat_vprint(file, SPLAT_MUTEX_TEST2_NAME,
|
||||||
@ -226,7 +220,6 @@ splat_mutex_test2(struct file *file, void *arg)
|
|||||||
destroy_workqueue(wq);
|
destroy_workqueue(wq);
|
||||||
out:
|
out:
|
||||||
kfree(mp);
|
kfree(mp);
|
||||||
#endif
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
/* INIT_WORK wants 3 args */
|
/* INIT_WORK wants 3 args */
|
||||||
#undef HAVE_3ARGS_INIT_WORK
|
#undef HAVE_3ARGS_INIT_WORK
|
||||||
|
|
||||||
|
/* on_each_cpu wants 3 args */
|
||||||
|
#undef HAVE_3ARGS_ON_EACH_CPU
|
||||||
|
|
||||||
/* kernel defines atomic64_t */
|
/* kernel defines atomic64_t */
|
||||||
#undef HAVE_ATOMIC64_T
|
#undef HAVE_ATOMIC64_T
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user